smart-downscaler 0.3.6 → 0.3.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/smart_downscaler.d.ts +21 -152
- package/smart_downscaler.js +1 -1
- package/smart_downscaler_bg.js +89 -817
- package/smart_downscaler_bg.wasm +0 -0
package/package.json
CHANGED
package/smart_downscaler.d.ts
CHANGED
|
@@ -1,165 +1,34 @@
|
|
|
1
1
|
/* tslint:disable */
|
|
2
2
|
/* eslint-disable */
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
* Result of color analysis
|
|
6
|
-
*/
|
|
7
|
-
export class ColorAnalysisResult {
|
|
8
|
-
private constructor();
|
|
4
|
+
export class SmartDownscaler {
|
|
9
5
|
free(): void;
|
|
10
6
|
[Symbol.dispose](): void;
|
|
11
|
-
/**
|
|
12
|
-
* Get color at index
|
|
13
|
-
*/
|
|
14
|
-
get_color(index: number): ColorEntry | undefined;
|
|
15
|
-
/**
|
|
16
|
-
* Get all colors as a flat array: [r, g, b, count(4 bytes), percentage(4 bytes), ...]
|
|
17
|
-
* Each color is 11 bytes
|
|
18
|
-
*/
|
|
19
|
-
get_colors_flat(): Uint8Array;
|
|
20
|
-
/**
|
|
21
|
-
* Get colors as JSON-compatible array
|
|
22
|
-
*/
|
|
23
|
-
to_json(): any;
|
|
24
|
-
readonly color_count: number;
|
|
25
|
-
readonly success: boolean;
|
|
26
|
-
readonly total_pixels: number;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* A single color entry with statistics
|
|
31
|
-
*/
|
|
32
|
-
export class ColorEntry {
|
|
33
|
-
private constructor();
|
|
34
|
-
free(): void;
|
|
35
|
-
[Symbol.dispose](): void;
|
|
36
|
-
readonly b: number;
|
|
37
|
-
readonly count: number;
|
|
38
|
-
readonly g: number;
|
|
39
|
-
readonly hex: string;
|
|
40
|
-
readonly percentage: number;
|
|
41
|
-
readonly r: number;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export class WasmDownscaleConfig {
|
|
45
|
-
free(): void;
|
|
46
|
-
[Symbol.dispose](): void;
|
|
47
|
-
static exact_colors(): WasmDownscaleConfig;
|
|
48
|
-
static fast(): WasmDownscaleConfig;
|
|
49
7
|
constructor();
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
max_resolution_mp: number;
|
|
66
|
-
neighbor_weight: number;
|
|
67
|
-
palette_size: number;
|
|
68
|
-
refinement_iterations: number;
|
|
69
|
-
region_weight: number;
|
|
70
|
-
slic_compactness: number;
|
|
71
|
-
slic_superpixels: number;
|
|
72
|
-
two_pass_refinement: boolean;
|
|
73
|
-
palette_strategy: string;
|
|
74
|
-
segmentation_method: string;
|
|
8
|
+
process(image_data: Uint8Array, width: number, height: number, target_width: number, target_height: number): WasmDownscaleResult;
|
|
9
|
+
set_edge_weight(weight: number): void;
|
|
10
|
+
set_hierarchy_params(threshold: number): void;
|
|
11
|
+
set_k_centroid(k: number): void;
|
|
12
|
+
set_k_centroid_iterations(iterations: number): void;
|
|
13
|
+
set_kmeans_iterations(iterations: number): void;
|
|
14
|
+
set_max_color_preprocess(count: number): void;
|
|
15
|
+
set_max_resolution(mp: number): void;
|
|
16
|
+
set_neighbor_weight(weight: number): void;
|
|
17
|
+
set_palette_size(size: number): void;
|
|
18
|
+
set_palette_strategy(strategy: number): void;
|
|
19
|
+
set_refinement_iterations(iterations: number): void;
|
|
20
|
+
set_region_weight(weight: number): void;
|
|
21
|
+
set_segmentation_method(method: number): void;
|
|
22
|
+
set_slic_params(region_size: number, _compactness: number, _iterations: number): void;
|
|
75
23
|
}
|
|
76
24
|
|
|
77
25
|
export class WasmDownscaleResult {
|
|
78
26
|
private constructor();
|
|
79
27
|
free(): void;
|
|
80
28
|
[Symbol.dispose](): void;
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
readonly palette_size: number;
|
|
87
|
-
readonly width: number;
|
|
29
|
+
get_indices(): Uint8Array;
|
|
30
|
+
get_palette_data(): Uint8Array;
|
|
31
|
+
get_rgba_data(): Uint8Array;
|
|
32
|
+
height(): number;
|
|
33
|
+
width(): number;
|
|
88
34
|
}
|
|
89
|
-
|
|
90
|
-
/**
|
|
91
|
-
* Analyze colors in an image
|
|
92
|
-
*
|
|
93
|
-
* # Arguments
|
|
94
|
-
* * `image_data` - RGBA pixel data
|
|
95
|
-
* * `max_colors` - Maximum number of unique colors to track (stops if exceeded)
|
|
96
|
-
* * `sort_method` - Sorting method: "frequency", "morton", or "hilbert"
|
|
97
|
-
*
|
|
98
|
-
* # Returns
|
|
99
|
-
* ColorAnalysisResult with array of colors (r, g, b, count, percentage, hex)
|
|
100
|
-
* If unique colors exceed max_colors, returns early with success=false
|
|
101
|
-
*/
|
|
102
|
-
export function analyze_colors(image_data: Uint8Array, max_colors: number, sort_method: string): ColorAnalysisResult;
|
|
103
|
-
|
|
104
|
-
/**
|
|
105
|
-
* Compute perceptual color distance between two RGB colors
|
|
106
|
-
*/
|
|
107
|
-
export function color_distance(r1: number, g1: number, b1: number, r2: number, g2: number, b2: number): number;
|
|
108
|
-
|
|
109
|
-
export function downscale(image_data: Uint8Array, width: number, height: number, target_width: number, target_height: number, config?: WasmDownscaleConfig | null): WasmDownscaleResult;
|
|
110
|
-
|
|
111
|
-
export function downscale_rgba(image_data: Uint8ClampedArray, width: number, height: number, target_width: number, target_height: number, config?: WasmDownscaleConfig | null): WasmDownscaleResult;
|
|
112
|
-
|
|
113
|
-
/**
|
|
114
|
-
* Simple downscale function with minimal parameters
|
|
115
|
-
*/
|
|
116
|
-
export function downscale_simple(image_data: Uint8Array, width: number, height: number, target_width: number, target_height: number, num_colors: number): WasmDownscaleResult;
|
|
117
|
-
|
|
118
|
-
export function downscale_with_palette(image_data: Uint8Array, width: number, height: number, target_width: number, target_height: number, palette_data: Uint8Array, config?: WasmDownscaleConfig | null): WasmDownscaleResult;
|
|
119
|
-
|
|
120
|
-
/**
|
|
121
|
-
* Extract a color palette from an image without downscaling
|
|
122
|
-
*/
|
|
123
|
-
export function extract_palette_from_image(image_data: Uint8Array, _width: number, _height: number, num_colors: number, kmeans_iterations: number, strategy?: string | null): Uint8Array;
|
|
124
|
-
|
|
125
|
-
/**
|
|
126
|
-
* Get chroma (saturation) of an RGB color
|
|
127
|
-
*/
|
|
128
|
-
export function get_chroma(r: number, g: number, b: number): number;
|
|
129
|
-
|
|
130
|
-
/**
|
|
131
|
-
* Get lightness of an RGB color in Oklab space
|
|
132
|
-
*/
|
|
133
|
-
export function get_lightness(r: number, g: number, b: number): number;
|
|
134
|
-
|
|
135
|
-
/**
|
|
136
|
-
* Get available palette strategies
|
|
137
|
-
*/
|
|
138
|
-
export function get_palette_strategies(): Array<any>;
|
|
139
|
-
|
|
140
|
-
export function init(): void;
|
|
141
|
-
|
|
142
|
-
/**
|
|
143
|
-
* Log a message to the browser console (for debugging)
|
|
144
|
-
*/
|
|
145
|
-
export function log(message: string): void;
|
|
146
|
-
|
|
147
|
-
/**
|
|
148
|
-
* Convert Oklab to RGB (utility function for JS)
|
|
149
|
-
*/
|
|
150
|
-
export function oklab_to_rgb(l: number, a: number, b: number): Uint8Array;
|
|
151
|
-
|
|
152
|
-
/**
|
|
153
|
-
* Quantize an image to a specific palette without resizing
|
|
154
|
-
*/
|
|
155
|
-
export function quantize_to_palette(image_data: Uint8Array, width: number, height: number, palette_data: Uint8Array): WasmDownscaleResult;
|
|
156
|
-
|
|
157
|
-
/**
|
|
158
|
-
* Convert RGB to Oklab (utility function for JS)
|
|
159
|
-
*/
|
|
160
|
-
export function rgb_to_oklab(r: number, g: number, b: number): Float32Array;
|
|
161
|
-
|
|
162
|
-
/**
|
|
163
|
-
* Get library version
|
|
164
|
-
*/
|
|
165
|
-
export function version(): string;
|
package/smart_downscaler.js
CHANGED
|
@@ -5,5 +5,5 @@ import { __wbg_set_wasm } from "./smart_downscaler_bg.js";
|
|
|
5
5
|
__wbg_set_wasm(wasm);
|
|
6
6
|
wasm.__wbindgen_start();
|
|
7
7
|
export {
|
|
8
|
-
|
|
8
|
+
SmartDownscaler, WasmDownscaleResult
|
|
9
9
|
} from "./smart_downscaler_bg.js";
|
package/smart_downscaler_bg.js
CHANGED
|
@@ -1,450 +1,122 @@
|
|
|
1
|
-
|
|
2
|
-
* Result of color analysis
|
|
3
|
-
*/
|
|
4
|
-
export class ColorAnalysisResult {
|
|
5
|
-
static __wrap(ptr) {
|
|
6
|
-
ptr = ptr >>> 0;
|
|
7
|
-
const obj = Object.create(ColorAnalysisResult.prototype);
|
|
8
|
-
obj.__wbg_ptr = ptr;
|
|
9
|
-
ColorAnalysisResultFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
10
|
-
return obj;
|
|
11
|
-
}
|
|
12
|
-
__destroy_into_raw() {
|
|
13
|
-
const ptr = this.__wbg_ptr;
|
|
14
|
-
this.__wbg_ptr = 0;
|
|
15
|
-
ColorAnalysisResultFinalization.unregister(this);
|
|
16
|
-
return ptr;
|
|
17
|
-
}
|
|
18
|
-
free() {
|
|
19
|
-
const ptr = this.__destroy_into_raw();
|
|
20
|
-
wasm.__wbg_coloranalysisresult_free(ptr, 0);
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* @returns {number}
|
|
24
|
-
*/
|
|
25
|
-
get color_count() {
|
|
26
|
-
const ret = wasm.coloranalysisresult_color_count(this.__wbg_ptr);
|
|
27
|
-
return ret >>> 0;
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Get color at index
|
|
31
|
-
* @param {number} index
|
|
32
|
-
* @returns {ColorEntry | undefined}
|
|
33
|
-
*/
|
|
34
|
-
get_color(index) {
|
|
35
|
-
const ret = wasm.coloranalysisresult_get_color(this.__wbg_ptr, index);
|
|
36
|
-
return ret === 0 ? undefined : ColorEntry.__wrap(ret);
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Get all colors as a flat array: [r, g, b, count(4 bytes), percentage(4 bytes), ...]
|
|
40
|
-
* Each color is 11 bytes
|
|
41
|
-
* @returns {Uint8Array}
|
|
42
|
-
*/
|
|
43
|
-
get_colors_flat() {
|
|
44
|
-
const ret = wasm.coloranalysisresult_get_colors_flat(this.__wbg_ptr);
|
|
45
|
-
return ret;
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* @returns {boolean}
|
|
49
|
-
*/
|
|
50
|
-
get success() {
|
|
51
|
-
const ret = wasm.coloranalysisresult_success(this.__wbg_ptr);
|
|
52
|
-
return ret !== 0;
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* Get colors as JSON-compatible array
|
|
56
|
-
* @returns {any}
|
|
57
|
-
*/
|
|
58
|
-
to_json() {
|
|
59
|
-
const ret = wasm.coloranalysisresult_to_json(this.__wbg_ptr);
|
|
60
|
-
if (ret[2]) {
|
|
61
|
-
throw takeFromExternrefTable0(ret[1]);
|
|
62
|
-
}
|
|
63
|
-
return takeFromExternrefTable0(ret[0]);
|
|
64
|
-
}
|
|
65
|
-
/**
|
|
66
|
-
* @returns {number}
|
|
67
|
-
*/
|
|
68
|
-
get total_pixels() {
|
|
69
|
-
const ret = wasm.coloranalysisresult_total_pixels(this.__wbg_ptr);
|
|
70
|
-
return ret >>> 0;
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
if (Symbol.dispose) ColorAnalysisResult.prototype[Symbol.dispose] = ColorAnalysisResult.prototype.free;
|
|
74
|
-
|
|
75
|
-
/**
|
|
76
|
-
* A single color entry with statistics
|
|
77
|
-
*/
|
|
78
|
-
export class ColorEntry {
|
|
79
|
-
static __wrap(ptr) {
|
|
80
|
-
ptr = ptr >>> 0;
|
|
81
|
-
const obj = Object.create(ColorEntry.prototype);
|
|
82
|
-
obj.__wbg_ptr = ptr;
|
|
83
|
-
ColorEntryFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
84
|
-
return obj;
|
|
85
|
-
}
|
|
86
|
-
__destroy_into_raw() {
|
|
87
|
-
const ptr = this.__wbg_ptr;
|
|
88
|
-
this.__wbg_ptr = 0;
|
|
89
|
-
ColorEntryFinalization.unregister(this);
|
|
90
|
-
return ptr;
|
|
91
|
-
}
|
|
92
|
-
free() {
|
|
93
|
-
const ptr = this.__destroy_into_raw();
|
|
94
|
-
wasm.__wbg_colorentry_free(ptr, 0);
|
|
95
|
-
}
|
|
96
|
-
/**
|
|
97
|
-
* @returns {number}
|
|
98
|
-
*/
|
|
99
|
-
get b() {
|
|
100
|
-
const ret = wasm.colorentry_b(this.__wbg_ptr);
|
|
101
|
-
return ret;
|
|
102
|
-
}
|
|
103
|
-
/**
|
|
104
|
-
* @returns {number}
|
|
105
|
-
*/
|
|
106
|
-
get count() {
|
|
107
|
-
const ret = wasm.colorentry_count(this.__wbg_ptr);
|
|
108
|
-
return ret >>> 0;
|
|
109
|
-
}
|
|
110
|
-
/**
|
|
111
|
-
* @returns {number}
|
|
112
|
-
*/
|
|
113
|
-
get g() {
|
|
114
|
-
const ret = wasm.colorentry_g(this.__wbg_ptr);
|
|
115
|
-
return ret;
|
|
116
|
-
}
|
|
117
|
-
/**
|
|
118
|
-
* @returns {string}
|
|
119
|
-
*/
|
|
120
|
-
get hex() {
|
|
121
|
-
let deferred1_0;
|
|
122
|
-
let deferred1_1;
|
|
123
|
-
try {
|
|
124
|
-
const ret = wasm.colorentry_hex(this.__wbg_ptr);
|
|
125
|
-
deferred1_0 = ret[0];
|
|
126
|
-
deferred1_1 = ret[1];
|
|
127
|
-
return getStringFromWasm0(ret[0], ret[1]);
|
|
128
|
-
} finally {
|
|
129
|
-
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
/**
|
|
133
|
-
* @returns {number}
|
|
134
|
-
*/
|
|
135
|
-
get percentage() {
|
|
136
|
-
const ret = wasm.colorentry_percentage(this.__wbg_ptr);
|
|
137
|
-
return ret;
|
|
138
|
-
}
|
|
139
|
-
/**
|
|
140
|
-
* @returns {number}
|
|
141
|
-
*/
|
|
142
|
-
get r() {
|
|
143
|
-
const ret = wasm.colorentry_r(this.__wbg_ptr);
|
|
144
|
-
return ret;
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
if (Symbol.dispose) ColorEntry.prototype[Symbol.dispose] = ColorEntry.prototype.free;
|
|
148
|
-
|
|
149
|
-
export class WasmDownscaleConfig {
|
|
150
|
-
static __wrap(ptr) {
|
|
151
|
-
ptr = ptr >>> 0;
|
|
152
|
-
const obj = Object.create(WasmDownscaleConfig.prototype);
|
|
153
|
-
obj.__wbg_ptr = ptr;
|
|
154
|
-
WasmDownscaleConfigFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
155
|
-
return obj;
|
|
156
|
-
}
|
|
1
|
+
export class SmartDownscaler {
|
|
157
2
|
__destroy_into_raw() {
|
|
158
3
|
const ptr = this.__wbg_ptr;
|
|
159
4
|
this.__wbg_ptr = 0;
|
|
160
|
-
|
|
5
|
+
SmartDownscalerFinalization.unregister(this);
|
|
161
6
|
return ptr;
|
|
162
7
|
}
|
|
163
8
|
free() {
|
|
164
9
|
const ptr = this.__destroy_into_raw();
|
|
165
|
-
wasm.
|
|
166
|
-
}
|
|
167
|
-
/**
|
|
168
|
-
* @returns {number}
|
|
169
|
-
*/
|
|
170
|
-
get edge_weight() {
|
|
171
|
-
const ret = wasm.__wbg_get_wasmdownscaleconfig_edge_weight(this.__wbg_ptr);
|
|
172
|
-
return ret;
|
|
173
|
-
}
|
|
174
|
-
/**
|
|
175
|
-
* @returns {number}
|
|
176
|
-
*/
|
|
177
|
-
get hierarchy_min_size() {
|
|
178
|
-
const ret = wasm.__wbg_get_wasmdownscaleconfig_hierarchy_min_size(this.__wbg_ptr);
|
|
179
|
-
return ret >>> 0;
|
|
180
|
-
}
|
|
181
|
-
/**
|
|
182
|
-
* @returns {number}
|
|
183
|
-
*/
|
|
184
|
-
get hierarchy_threshold() {
|
|
185
|
-
const ret = wasm.__wbg_get_wasmdownscaleconfig_hierarchy_threshold(this.__wbg_ptr);
|
|
186
|
-
return ret;
|
|
187
|
-
}
|
|
188
|
-
/**
|
|
189
|
-
* Iterations for tile centroid
|
|
190
|
-
* @returns {number}
|
|
191
|
-
*/
|
|
192
|
-
get k_centroid_iterations() {
|
|
193
|
-
const ret = wasm.__wbg_get_wasmdownscaleconfig_k_centroid_iterations(this.__wbg_ptr);
|
|
194
|
-
return ret >>> 0;
|
|
195
|
-
}
|
|
196
|
-
/**
|
|
197
|
-
* K-Means centroid mode (1=Avg, 2=Dom, 3=Foremost)
|
|
198
|
-
* @returns {number}
|
|
199
|
-
*/
|
|
200
|
-
get k_centroid() {
|
|
201
|
-
const ret = wasm.__wbg_get_wasmdownscaleconfig_k_centroid(this.__wbg_ptr);
|
|
202
|
-
return ret >>> 0;
|
|
10
|
+
wasm.__wbg_smartdownscaler_free(ptr, 0);
|
|
203
11
|
}
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
return ret >>> 0;
|
|
210
|
-
}
|
|
211
|
-
/**
|
|
212
|
-
* @returns {number}
|
|
213
|
-
*/
|
|
214
|
-
get max_color_preprocess() {
|
|
215
|
-
const ret = wasm.__wbg_get_wasmdownscaleconfig_max_color_preprocess(this.__wbg_ptr);
|
|
216
|
-
return ret >>> 0;
|
|
217
|
-
}
|
|
218
|
-
/**
|
|
219
|
-
* @returns {number}
|
|
220
|
-
*/
|
|
221
|
-
get max_resolution_mp() {
|
|
222
|
-
const ret = wasm.__wbg_get_wasmdownscaleconfig_max_resolution_mp(this.__wbg_ptr);
|
|
223
|
-
return ret;
|
|
224
|
-
}
|
|
225
|
-
/**
|
|
226
|
-
* @returns {number}
|
|
227
|
-
*/
|
|
228
|
-
get neighbor_weight() {
|
|
229
|
-
const ret = wasm.__wbg_get_wasmdownscaleconfig_neighbor_weight(this.__wbg_ptr);
|
|
230
|
-
return ret;
|
|
231
|
-
}
|
|
232
|
-
/**
|
|
233
|
-
* @returns {number}
|
|
234
|
-
*/
|
|
235
|
-
get palette_size() {
|
|
236
|
-
const ret = wasm.__wbg_get_wasmdownscaleconfig_palette_size(this.__wbg_ptr);
|
|
237
|
-
return ret >>> 0;
|
|
238
|
-
}
|
|
239
|
-
/**
|
|
240
|
-
* @returns {number}
|
|
241
|
-
*/
|
|
242
|
-
get refinement_iterations() {
|
|
243
|
-
const ret = wasm.__wbg_get_wasmdownscaleconfig_refinement_iterations(this.__wbg_ptr);
|
|
244
|
-
return ret >>> 0;
|
|
245
|
-
}
|
|
246
|
-
/**
|
|
247
|
-
* @returns {number}
|
|
248
|
-
*/
|
|
249
|
-
get region_weight() {
|
|
250
|
-
const ret = wasm.__wbg_get_wasmdownscaleconfig_region_weight(this.__wbg_ptr);
|
|
251
|
-
return ret;
|
|
252
|
-
}
|
|
253
|
-
/**
|
|
254
|
-
* @returns {number}
|
|
255
|
-
*/
|
|
256
|
-
get slic_compactness() {
|
|
257
|
-
const ret = wasm.__wbg_get_wasmdownscaleconfig_slic_compactness(this.__wbg_ptr);
|
|
258
|
-
return ret;
|
|
259
|
-
}
|
|
260
|
-
/**
|
|
261
|
-
* @returns {number}
|
|
262
|
-
*/
|
|
263
|
-
get slic_superpixels() {
|
|
264
|
-
const ret = wasm.__wbg_get_wasmdownscaleconfig_slic_superpixels(this.__wbg_ptr);
|
|
265
|
-
return ret >>> 0;
|
|
266
|
-
}
|
|
267
|
-
/**
|
|
268
|
-
* @returns {boolean}
|
|
269
|
-
*/
|
|
270
|
-
get two_pass_refinement() {
|
|
271
|
-
const ret = wasm.__wbg_get_wasmdownscaleconfig_two_pass_refinement(this.__wbg_ptr);
|
|
272
|
-
return ret !== 0;
|
|
273
|
-
}
|
|
274
|
-
/**
|
|
275
|
-
* @param {number} arg0
|
|
276
|
-
*/
|
|
277
|
-
set edge_weight(arg0) {
|
|
278
|
-
wasm.__wbg_set_wasmdownscaleconfig_edge_weight(this.__wbg_ptr, arg0);
|
|
279
|
-
}
|
|
280
|
-
/**
|
|
281
|
-
* @param {number} arg0
|
|
282
|
-
*/
|
|
283
|
-
set hierarchy_min_size(arg0) {
|
|
284
|
-
wasm.__wbg_set_wasmdownscaleconfig_hierarchy_min_size(this.__wbg_ptr, arg0);
|
|
285
|
-
}
|
|
286
|
-
/**
|
|
287
|
-
* @param {number} arg0
|
|
288
|
-
*/
|
|
289
|
-
set hierarchy_threshold(arg0) {
|
|
290
|
-
wasm.__wbg_set_wasmdownscaleconfig_hierarchy_threshold(this.__wbg_ptr, arg0);
|
|
291
|
-
}
|
|
292
|
-
/**
|
|
293
|
-
* Iterations for tile centroid
|
|
294
|
-
* @param {number} arg0
|
|
295
|
-
*/
|
|
296
|
-
set k_centroid_iterations(arg0) {
|
|
297
|
-
wasm.__wbg_set_wasmdownscaleconfig_k_centroid_iterations(this.__wbg_ptr, arg0);
|
|
298
|
-
}
|
|
299
|
-
/**
|
|
300
|
-
* K-Means centroid mode (1=Avg, 2=Dom, 3=Foremost)
|
|
301
|
-
* @param {number} arg0
|
|
302
|
-
*/
|
|
303
|
-
set k_centroid(arg0) {
|
|
304
|
-
wasm.__wbg_set_wasmdownscaleconfig_k_centroid(this.__wbg_ptr, arg0);
|
|
305
|
-
}
|
|
306
|
-
/**
|
|
307
|
-
* @param {number} arg0
|
|
308
|
-
*/
|
|
309
|
-
set kmeans_iterations(arg0) {
|
|
310
|
-
wasm.__wbg_set_wasmdownscaleconfig_kmeans_iterations(this.__wbg_ptr, arg0);
|
|
311
|
-
}
|
|
312
|
-
/**
|
|
313
|
-
* @param {number} arg0
|
|
314
|
-
*/
|
|
315
|
-
set max_color_preprocess(arg0) {
|
|
316
|
-
wasm.__wbg_set_wasmdownscaleconfig_max_color_preprocess(this.__wbg_ptr, arg0);
|
|
317
|
-
}
|
|
318
|
-
/**
|
|
319
|
-
* @param {number} arg0
|
|
320
|
-
*/
|
|
321
|
-
set max_resolution_mp(arg0) {
|
|
322
|
-
wasm.__wbg_set_wasmdownscaleconfig_max_resolution_mp(this.__wbg_ptr, arg0);
|
|
12
|
+
constructor() {
|
|
13
|
+
const ret = wasm.smartdownscaler_new();
|
|
14
|
+
this.__wbg_ptr = ret >>> 0;
|
|
15
|
+
SmartDownscalerFinalization.register(this, this.__wbg_ptr, this);
|
|
16
|
+
return this;
|
|
323
17
|
}
|
|
324
18
|
/**
|
|
325
|
-
* @param {
|
|
19
|
+
* @param {Uint8Array} image_data
|
|
20
|
+
* @param {number} width
|
|
21
|
+
* @param {number} height
|
|
22
|
+
* @param {number} target_width
|
|
23
|
+
* @param {number} target_height
|
|
24
|
+
* @returns {WasmDownscaleResult}
|
|
326
25
|
*/
|
|
327
|
-
|
|
328
|
-
|
|
26
|
+
process(image_data, width, height, target_width, target_height) {
|
|
27
|
+
const ptr0 = passArray8ToWasm0(image_data, wasm.__wbindgen_malloc);
|
|
28
|
+
const len0 = WASM_VECTOR_LEN;
|
|
29
|
+
const ret = wasm.smartdownscaler_process(this.__wbg_ptr, ptr0, len0, width, height, target_width, target_height);
|
|
30
|
+
return WasmDownscaleResult.__wrap(ret);
|
|
329
31
|
}
|
|
330
32
|
/**
|
|
331
|
-
* @param {number}
|
|
33
|
+
* @param {number} weight
|
|
332
34
|
*/
|
|
333
|
-
|
|
334
|
-
wasm.
|
|
35
|
+
set_edge_weight(weight) {
|
|
36
|
+
wasm.smartdownscaler_set_edge_weight(this.__wbg_ptr, weight);
|
|
335
37
|
}
|
|
336
38
|
/**
|
|
337
|
-
* @param {number}
|
|
39
|
+
* @param {number} threshold
|
|
338
40
|
*/
|
|
339
|
-
|
|
340
|
-
wasm.
|
|
41
|
+
set_hierarchy_params(threshold) {
|
|
42
|
+
wasm.smartdownscaler_set_hierarchy_params(this.__wbg_ptr, threshold);
|
|
341
43
|
}
|
|
342
44
|
/**
|
|
343
|
-
* @param {number}
|
|
45
|
+
* @param {number} k
|
|
344
46
|
*/
|
|
345
|
-
|
|
346
|
-
wasm.
|
|
47
|
+
set_k_centroid(k) {
|
|
48
|
+
wasm.smartdownscaler_set_k_centroid(this.__wbg_ptr, k);
|
|
347
49
|
}
|
|
348
50
|
/**
|
|
349
|
-
* @param {number}
|
|
51
|
+
* @param {number} iterations
|
|
350
52
|
*/
|
|
351
|
-
|
|
352
|
-
wasm.
|
|
53
|
+
set_k_centroid_iterations(iterations) {
|
|
54
|
+
wasm.smartdownscaler_set_k_centroid_iterations(this.__wbg_ptr, iterations);
|
|
353
55
|
}
|
|
354
56
|
/**
|
|
355
|
-
* @param {number}
|
|
57
|
+
* @param {number} iterations
|
|
356
58
|
*/
|
|
357
|
-
|
|
358
|
-
wasm.
|
|
59
|
+
set_kmeans_iterations(iterations) {
|
|
60
|
+
wasm.smartdownscaler_set_kmeans_iterations(this.__wbg_ptr, iterations);
|
|
359
61
|
}
|
|
360
62
|
/**
|
|
361
|
-
* @param {
|
|
63
|
+
* @param {number} count
|
|
362
64
|
*/
|
|
363
|
-
|
|
364
|
-
wasm.
|
|
65
|
+
set_max_color_preprocess(count) {
|
|
66
|
+
wasm.smartdownscaler_set_max_color_preprocess(this.__wbg_ptr, count);
|
|
365
67
|
}
|
|
366
68
|
/**
|
|
367
|
-
* @
|
|
69
|
+
* @param {number} mp
|
|
368
70
|
*/
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
return WasmDownscaleConfig.__wrap(ret);
|
|
71
|
+
set_max_resolution(mp) {
|
|
72
|
+
wasm.smartdownscaler_set_max_resolution(this.__wbg_ptr, mp);
|
|
372
73
|
}
|
|
373
74
|
/**
|
|
374
|
-
* @
|
|
75
|
+
* @param {number} weight
|
|
375
76
|
*/
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
return WasmDownscaleConfig.__wrap(ret);
|
|
379
|
-
}
|
|
380
|
-
constructor() {
|
|
381
|
-
const ret = wasm.wasmdownscaleconfig_new();
|
|
382
|
-
this.__wbg_ptr = ret >>> 0;
|
|
383
|
-
WasmDownscaleConfigFinalization.register(this, this.__wbg_ptr, this);
|
|
384
|
-
return this;
|
|
77
|
+
set_neighbor_weight(weight) {
|
|
78
|
+
wasm.smartdownscaler_set_neighbor_weight(this.__wbg_ptr, weight);
|
|
385
79
|
}
|
|
386
80
|
/**
|
|
387
|
-
* @
|
|
81
|
+
* @param {number} size
|
|
388
82
|
*/
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
let deferred1_1;
|
|
392
|
-
try {
|
|
393
|
-
const ret = wasm.wasmdownscaleconfig_palette_strategy(this.__wbg_ptr);
|
|
394
|
-
deferred1_0 = ret[0];
|
|
395
|
-
deferred1_1 = ret[1];
|
|
396
|
-
return getStringFromWasm0(ret[0], ret[1]);
|
|
397
|
-
} finally {
|
|
398
|
-
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
399
|
-
}
|
|
83
|
+
set_palette_size(size) {
|
|
84
|
+
wasm.smartdownscaler_set_palette_size(this.__wbg_ptr, size);
|
|
400
85
|
}
|
|
401
86
|
/**
|
|
402
|
-
* @
|
|
87
|
+
* @param {number} strategy
|
|
403
88
|
*/
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
return WasmDownscaleConfig.__wrap(ret);
|
|
89
|
+
set_palette_strategy(strategy) {
|
|
90
|
+
wasm.smartdownscaler_set_palette_strategy(this.__wbg_ptr, strategy);
|
|
407
91
|
}
|
|
408
92
|
/**
|
|
409
|
-
* @
|
|
93
|
+
* @param {number} iterations
|
|
410
94
|
*/
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
let deferred1_1;
|
|
414
|
-
try {
|
|
415
|
-
const ret = wasm.wasmdownscaleconfig_segmentation_method(this.__wbg_ptr);
|
|
416
|
-
deferred1_0 = ret[0];
|
|
417
|
-
deferred1_1 = ret[1];
|
|
418
|
-
return getStringFromWasm0(ret[0], ret[1]);
|
|
419
|
-
} finally {
|
|
420
|
-
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
421
|
-
}
|
|
95
|
+
set_refinement_iterations(iterations) {
|
|
96
|
+
wasm.smartdownscaler_set_refinement_iterations(this.__wbg_ptr, iterations);
|
|
422
97
|
}
|
|
423
98
|
/**
|
|
424
|
-
* @param {
|
|
99
|
+
* @param {number} weight
|
|
425
100
|
*/
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
const len0 = WASM_VECTOR_LEN;
|
|
429
|
-
wasm.wasmdownscaleconfig_set_palette_strategy(this.__wbg_ptr, ptr0, len0);
|
|
101
|
+
set_region_weight(weight) {
|
|
102
|
+
wasm.smartdownscaler_set_region_weight(this.__wbg_ptr, weight);
|
|
430
103
|
}
|
|
431
104
|
/**
|
|
432
|
-
* @param {
|
|
105
|
+
* @param {number} method
|
|
433
106
|
*/
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
const len0 = WASM_VECTOR_LEN;
|
|
437
|
-
wasm.wasmdownscaleconfig_set_segmentation_method(this.__wbg_ptr, ptr0, len0);
|
|
107
|
+
set_segmentation_method(method) {
|
|
108
|
+
wasm.smartdownscaler_set_segmentation_method(this.__wbg_ptr, method);
|
|
438
109
|
}
|
|
439
110
|
/**
|
|
440
|
-
* @
|
|
111
|
+
* @param {number} region_size
|
|
112
|
+
* @param {number} _compactness
|
|
113
|
+
* @param {number} _iterations
|
|
441
114
|
*/
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
return WasmDownscaleConfig.__wrap(ret);
|
|
115
|
+
set_slic_params(region_size, _compactness, _iterations) {
|
|
116
|
+
wasm.smartdownscaler_set_slic_params(this.__wbg_ptr, region_size, _compactness, _iterations);
|
|
445
117
|
}
|
|
446
118
|
}
|
|
447
|
-
if (Symbol.dispose)
|
|
119
|
+
if (Symbol.dispose) SmartDownscaler.prototype[Symbol.dispose] = SmartDownscaler.prototype.free;
|
|
448
120
|
|
|
449
121
|
export class WasmDownscaleResult {
|
|
450
122
|
static __wrap(ptr) {
|
|
@@ -465,371 +137,51 @@ export class WasmDownscaleResult {
|
|
|
465
137
|
wasm.__wbg_wasmdownscaleresult_free(ptr, 0);
|
|
466
138
|
}
|
|
467
139
|
/**
|
|
468
|
-
* @returns {
|
|
469
|
-
*/
|
|
470
|
-
get data() {
|
|
471
|
-
const ret = wasm.wasmdownscaleresult_data(this.__wbg_ptr);
|
|
472
|
-
return ret;
|
|
473
|
-
}
|
|
474
|
-
/**
|
|
475
|
-
* @returns {number}
|
|
140
|
+
* @returns {Uint8Array}
|
|
476
141
|
*/
|
|
477
|
-
|
|
478
|
-
const ret = wasm.
|
|
479
|
-
|
|
142
|
+
get_indices() {
|
|
143
|
+
const ret = wasm.wasmdownscaleresult_get_indices(this.__wbg_ptr);
|
|
144
|
+
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
145
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
146
|
+
return v1;
|
|
480
147
|
}
|
|
481
148
|
/**
|
|
482
149
|
* @returns {Uint8Array}
|
|
483
150
|
*/
|
|
484
|
-
|
|
485
|
-
const ret = wasm.
|
|
486
|
-
|
|
151
|
+
get_palette_data() {
|
|
152
|
+
const ret = wasm.wasmdownscaleresult_get_palette_data(this.__wbg_ptr);
|
|
153
|
+
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
154
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
155
|
+
return v1;
|
|
487
156
|
}
|
|
488
157
|
/**
|
|
489
158
|
* @returns {Uint8Array}
|
|
490
159
|
*/
|
|
491
|
-
|
|
492
|
-
const ret = wasm.
|
|
493
|
-
|
|
160
|
+
get_rgba_data() {
|
|
161
|
+
const ret = wasm.wasmdownscaleresult_get_rgba_data(this.__wbg_ptr);
|
|
162
|
+
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
163
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
164
|
+
return v1;
|
|
494
165
|
}
|
|
495
166
|
/**
|
|
496
167
|
* @returns {number}
|
|
497
168
|
*/
|
|
498
|
-
|
|
499
|
-
const ret = wasm.
|
|
169
|
+
height() {
|
|
170
|
+
const ret = wasm.wasmdownscaleresult_height(this.__wbg_ptr);
|
|
500
171
|
return ret >>> 0;
|
|
501
172
|
}
|
|
502
|
-
/**
|
|
503
|
-
* @returns {Uint8Array}
|
|
504
|
-
*/
|
|
505
|
-
rgb_data() {
|
|
506
|
-
const ret = wasm.wasmdownscaleresult_rgb_data(this.__wbg_ptr);
|
|
507
|
-
return ret;
|
|
508
|
-
}
|
|
509
173
|
/**
|
|
510
174
|
* @returns {number}
|
|
511
175
|
*/
|
|
512
|
-
|
|
176
|
+
width() {
|
|
513
177
|
const ret = wasm.wasmdownscaleresult_width(this.__wbg_ptr);
|
|
514
178
|
return ret >>> 0;
|
|
515
179
|
}
|
|
516
180
|
}
|
|
517
181
|
if (Symbol.dispose) WasmDownscaleResult.prototype[Symbol.dispose] = WasmDownscaleResult.prototype.free;
|
|
518
|
-
|
|
519
|
-
/**
|
|
520
|
-
* Analyze colors in an image
|
|
521
|
-
*
|
|
522
|
-
* # Arguments
|
|
523
|
-
* * `image_data` - RGBA pixel data
|
|
524
|
-
* * `max_colors` - Maximum number of unique colors to track (stops if exceeded)
|
|
525
|
-
* * `sort_method` - Sorting method: "frequency", "morton", or "hilbert"
|
|
526
|
-
*
|
|
527
|
-
* # Returns
|
|
528
|
-
* ColorAnalysisResult with array of colors (r, g, b, count, percentage, hex)
|
|
529
|
-
* If unique colors exceed max_colors, returns early with success=false
|
|
530
|
-
* @param {Uint8Array} image_data
|
|
531
|
-
* @param {number} max_colors
|
|
532
|
-
* @param {string} sort_method
|
|
533
|
-
* @returns {ColorAnalysisResult}
|
|
534
|
-
*/
|
|
535
|
-
export function analyze_colors(image_data, max_colors, sort_method) {
|
|
536
|
-
const ptr0 = passStringToWasm0(sort_method, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
537
|
-
const len0 = WASM_VECTOR_LEN;
|
|
538
|
-
const ret = wasm.analyze_colors(image_data, max_colors, ptr0, len0);
|
|
539
|
-
if (ret[2]) {
|
|
540
|
-
throw takeFromExternrefTable0(ret[1]);
|
|
541
|
-
}
|
|
542
|
-
return ColorAnalysisResult.__wrap(ret[0]);
|
|
543
|
-
}
|
|
544
|
-
|
|
545
|
-
/**
|
|
546
|
-
* Compute perceptual color distance between two RGB colors
|
|
547
|
-
* @param {number} r1
|
|
548
|
-
* @param {number} g1
|
|
549
|
-
* @param {number} b1
|
|
550
|
-
* @param {number} r2
|
|
551
|
-
* @param {number} g2
|
|
552
|
-
* @param {number} b2
|
|
553
|
-
* @returns {number}
|
|
554
|
-
*/
|
|
555
|
-
export function color_distance(r1, g1, b1, r2, g2, b2) {
|
|
556
|
-
const ret = wasm.color_distance(r1, g1, b1, r2, g2, b2);
|
|
557
|
-
return ret;
|
|
558
|
-
}
|
|
559
|
-
|
|
560
|
-
/**
|
|
561
|
-
* @param {Uint8Array} image_data
|
|
562
|
-
* @param {number} width
|
|
563
|
-
* @param {number} height
|
|
564
|
-
* @param {number} target_width
|
|
565
|
-
* @param {number} target_height
|
|
566
|
-
* @param {WasmDownscaleConfig | null} [config]
|
|
567
|
-
* @returns {WasmDownscaleResult}
|
|
568
|
-
*/
|
|
569
|
-
export function downscale(image_data, width, height, target_width, target_height, config) {
|
|
570
|
-
let ptr0 = 0;
|
|
571
|
-
if (!isLikeNone(config)) {
|
|
572
|
-
_assertClass(config, WasmDownscaleConfig);
|
|
573
|
-
ptr0 = config.__destroy_into_raw();
|
|
574
|
-
}
|
|
575
|
-
const ret = wasm.downscale(image_data, width, height, target_width, target_height, ptr0);
|
|
576
|
-
if (ret[2]) {
|
|
577
|
-
throw takeFromExternrefTable0(ret[1]);
|
|
578
|
-
}
|
|
579
|
-
return WasmDownscaleResult.__wrap(ret[0]);
|
|
580
|
-
}
|
|
581
|
-
|
|
582
|
-
/**
|
|
583
|
-
* @param {Uint8ClampedArray} image_data
|
|
584
|
-
* @param {number} width
|
|
585
|
-
* @param {number} height
|
|
586
|
-
* @param {number} target_width
|
|
587
|
-
* @param {number} target_height
|
|
588
|
-
* @param {WasmDownscaleConfig | null} [config]
|
|
589
|
-
* @returns {WasmDownscaleResult}
|
|
590
|
-
*/
|
|
591
|
-
export function downscale_rgba(image_data, width, height, target_width, target_height, config) {
|
|
592
|
-
let ptr0 = 0;
|
|
593
|
-
if (!isLikeNone(config)) {
|
|
594
|
-
_assertClass(config, WasmDownscaleConfig);
|
|
595
|
-
ptr0 = config.__destroy_into_raw();
|
|
596
|
-
}
|
|
597
|
-
const ret = wasm.downscale_rgba(image_data, width, height, target_width, target_height, ptr0);
|
|
598
|
-
if (ret[2]) {
|
|
599
|
-
throw takeFromExternrefTable0(ret[1]);
|
|
600
|
-
}
|
|
601
|
-
return WasmDownscaleResult.__wrap(ret[0]);
|
|
602
|
-
}
|
|
603
|
-
|
|
604
|
-
/**
|
|
605
|
-
* Simple downscale function with minimal parameters
|
|
606
|
-
* @param {Uint8Array} image_data
|
|
607
|
-
* @param {number} width
|
|
608
|
-
* @param {number} height
|
|
609
|
-
* @param {number} target_width
|
|
610
|
-
* @param {number} target_height
|
|
611
|
-
* @param {number} num_colors
|
|
612
|
-
* @returns {WasmDownscaleResult}
|
|
613
|
-
*/
|
|
614
|
-
export function downscale_simple(image_data, width, height, target_width, target_height, num_colors) {
|
|
615
|
-
const ret = wasm.downscale_simple(image_data, width, height, target_width, target_height, num_colors);
|
|
616
|
-
if (ret[2]) {
|
|
617
|
-
throw takeFromExternrefTable0(ret[1]);
|
|
618
|
-
}
|
|
619
|
-
return WasmDownscaleResult.__wrap(ret[0]);
|
|
620
|
-
}
|
|
621
|
-
|
|
622
|
-
/**
|
|
623
|
-
* @param {Uint8Array} image_data
|
|
624
|
-
* @param {number} width
|
|
625
|
-
* @param {number} height
|
|
626
|
-
* @param {number} target_width
|
|
627
|
-
* @param {number} target_height
|
|
628
|
-
* @param {Uint8Array} palette_data
|
|
629
|
-
* @param {WasmDownscaleConfig | null} [config]
|
|
630
|
-
* @returns {WasmDownscaleResult}
|
|
631
|
-
*/
|
|
632
|
-
export function downscale_with_palette(image_data, width, height, target_width, target_height, palette_data, config) {
|
|
633
|
-
let ptr0 = 0;
|
|
634
|
-
if (!isLikeNone(config)) {
|
|
635
|
-
_assertClass(config, WasmDownscaleConfig);
|
|
636
|
-
ptr0 = config.__destroy_into_raw();
|
|
637
|
-
}
|
|
638
|
-
const ret = wasm.downscale_with_palette(image_data, width, height, target_width, target_height, palette_data, ptr0);
|
|
639
|
-
if (ret[2]) {
|
|
640
|
-
throw takeFromExternrefTable0(ret[1]);
|
|
641
|
-
}
|
|
642
|
-
return WasmDownscaleResult.__wrap(ret[0]);
|
|
643
|
-
}
|
|
644
|
-
|
|
645
|
-
/**
|
|
646
|
-
* Extract a color palette from an image without downscaling
|
|
647
|
-
* @param {Uint8Array} image_data
|
|
648
|
-
* @param {number} _width
|
|
649
|
-
* @param {number} _height
|
|
650
|
-
* @param {number} num_colors
|
|
651
|
-
* @param {number} kmeans_iterations
|
|
652
|
-
* @param {string | null} [strategy]
|
|
653
|
-
* @returns {Uint8Array}
|
|
654
|
-
*/
|
|
655
|
-
export function extract_palette_from_image(image_data, _width, _height, num_colors, kmeans_iterations, strategy) {
|
|
656
|
-
var ptr0 = isLikeNone(strategy) ? 0 : passStringToWasm0(strategy, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
657
|
-
var len0 = WASM_VECTOR_LEN;
|
|
658
|
-
const ret = wasm.extract_palette_from_image(image_data, _width, _height, num_colors, kmeans_iterations, ptr0, len0);
|
|
659
|
-
if (ret[2]) {
|
|
660
|
-
throw takeFromExternrefTable0(ret[1]);
|
|
661
|
-
}
|
|
662
|
-
return takeFromExternrefTable0(ret[0]);
|
|
663
|
-
}
|
|
664
|
-
|
|
665
|
-
/**
|
|
666
|
-
* Get chroma (saturation) of an RGB color
|
|
667
|
-
* @param {number} r
|
|
668
|
-
* @param {number} g
|
|
669
|
-
* @param {number} b
|
|
670
|
-
* @returns {number}
|
|
671
|
-
*/
|
|
672
|
-
export function get_chroma(r, g, b) {
|
|
673
|
-
const ret = wasm.get_chroma(r, g, b);
|
|
674
|
-
return ret;
|
|
675
|
-
}
|
|
676
|
-
|
|
677
|
-
/**
|
|
678
|
-
* Get lightness of an RGB color in Oklab space
|
|
679
|
-
* @param {number} r
|
|
680
|
-
* @param {number} g
|
|
681
|
-
* @param {number} b
|
|
682
|
-
* @returns {number}
|
|
683
|
-
*/
|
|
684
|
-
export function get_lightness(r, g, b) {
|
|
685
|
-
const ret = wasm.get_lightness(r, g, b);
|
|
686
|
-
return ret;
|
|
687
|
-
}
|
|
688
|
-
|
|
689
|
-
/**
|
|
690
|
-
* Get available palette strategies
|
|
691
|
-
* @returns {Array<any>}
|
|
692
|
-
*/
|
|
693
|
-
export function get_palette_strategies() {
|
|
694
|
-
const ret = wasm.get_palette_strategies();
|
|
695
|
-
return ret;
|
|
696
|
-
}
|
|
697
|
-
|
|
698
|
-
export function init() {
|
|
699
|
-
wasm.init();
|
|
700
|
-
}
|
|
701
|
-
|
|
702
|
-
/**
|
|
703
|
-
* Log a message to the browser console (for debugging)
|
|
704
|
-
* @param {string} message
|
|
705
|
-
*/
|
|
706
|
-
export function log(message) {
|
|
707
|
-
const ptr0 = passStringToWasm0(message, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
708
|
-
const len0 = WASM_VECTOR_LEN;
|
|
709
|
-
wasm.log(ptr0, len0);
|
|
710
|
-
}
|
|
711
|
-
|
|
712
|
-
/**
|
|
713
|
-
* Convert Oklab to RGB (utility function for JS)
|
|
714
|
-
* @param {number} l
|
|
715
|
-
* @param {number} a
|
|
716
|
-
* @param {number} b
|
|
717
|
-
* @returns {Uint8Array}
|
|
718
|
-
*/
|
|
719
|
-
export function oklab_to_rgb(l, a, b) {
|
|
720
|
-
const ret = wasm.oklab_to_rgb(l, a, b);
|
|
721
|
-
return ret;
|
|
722
|
-
}
|
|
723
|
-
|
|
724
|
-
/**
|
|
725
|
-
* Quantize an image to a specific palette without resizing
|
|
726
|
-
* @param {Uint8Array} image_data
|
|
727
|
-
* @param {number} width
|
|
728
|
-
* @param {number} height
|
|
729
|
-
* @param {Uint8Array} palette_data
|
|
730
|
-
* @returns {WasmDownscaleResult}
|
|
731
|
-
*/
|
|
732
|
-
export function quantize_to_palette(image_data, width, height, palette_data) {
|
|
733
|
-
const ret = wasm.quantize_to_palette(image_data, width, height, palette_data);
|
|
734
|
-
if (ret[2]) {
|
|
735
|
-
throw takeFromExternrefTable0(ret[1]);
|
|
736
|
-
}
|
|
737
|
-
return WasmDownscaleResult.__wrap(ret[0]);
|
|
738
|
-
}
|
|
739
|
-
|
|
740
|
-
/**
|
|
741
|
-
* Convert RGB to Oklab (utility function for JS)
|
|
742
|
-
* @param {number} r
|
|
743
|
-
* @param {number} g
|
|
744
|
-
* @param {number} b
|
|
745
|
-
* @returns {Float32Array}
|
|
746
|
-
*/
|
|
747
|
-
export function rgb_to_oklab(r, g, b) {
|
|
748
|
-
const ret = wasm.rgb_to_oklab(r, g, b);
|
|
749
|
-
return ret;
|
|
750
|
-
}
|
|
751
|
-
|
|
752
|
-
/**
|
|
753
|
-
* Get library version
|
|
754
|
-
* @returns {string}
|
|
755
|
-
*/
|
|
756
|
-
export function version() {
|
|
757
|
-
let deferred1_0;
|
|
758
|
-
let deferred1_1;
|
|
759
|
-
try {
|
|
760
|
-
const ret = wasm.version();
|
|
761
|
-
deferred1_0 = ret[0];
|
|
762
|
-
deferred1_1 = ret[1];
|
|
763
|
-
return getStringFromWasm0(ret[0], ret[1]);
|
|
764
|
-
} finally {
|
|
765
|
-
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
766
|
-
}
|
|
767
|
-
}
|
|
768
182
|
export function __wbg___wbindgen_throw_be289d5034ed271b(arg0, arg1) {
|
|
769
183
|
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
770
184
|
}
|
|
771
|
-
export function __wbg_length_32ed9a279acd054c(arg0) {
|
|
772
|
-
const ret = arg0.length;
|
|
773
|
-
return ret;
|
|
774
|
-
}
|
|
775
|
-
export function __wbg_log_6b5ca2e6124b2808(arg0) {
|
|
776
|
-
console.log(arg0);
|
|
777
|
-
}
|
|
778
|
-
export function __wbg_new_361308b2356cecd0() {
|
|
779
|
-
const ret = new Object();
|
|
780
|
-
return ret;
|
|
781
|
-
}
|
|
782
|
-
export function __wbg_new_3eb36ae241fe6f44() {
|
|
783
|
-
const ret = new Array();
|
|
784
|
-
return ret;
|
|
785
|
-
}
|
|
786
|
-
export function __wbg_new_dd2b680c8bf6ae29(arg0) {
|
|
787
|
-
const ret = new Uint8Array(arg0);
|
|
788
|
-
return ret;
|
|
789
|
-
}
|
|
790
|
-
export function __wbg_new_from_slice_48496fd78013671b(arg0, arg1) {
|
|
791
|
-
const ret = new Uint8ClampedArray(getArrayU8FromWasm0(arg0, arg1));
|
|
792
|
-
return ret;
|
|
793
|
-
}
|
|
794
|
-
export function __wbg_new_from_slice_a3d2629dc1826784(arg0, arg1) {
|
|
795
|
-
const ret = new Uint8Array(getArrayU8FromWasm0(arg0, arg1));
|
|
796
|
-
return ret;
|
|
797
|
-
}
|
|
798
|
-
export function __wbg_new_with_length_63f2683cc2521026(arg0) {
|
|
799
|
-
const ret = new Float32Array(arg0 >>> 0);
|
|
800
|
-
return ret;
|
|
801
|
-
}
|
|
802
|
-
export function __wbg_new_with_length_a2c39cbe88fd8ff1(arg0) {
|
|
803
|
-
const ret = new Uint8Array(arg0 >>> 0);
|
|
804
|
-
return ret;
|
|
805
|
-
}
|
|
806
|
-
export function __wbg_prototypesetcall_bdcdcc5842e4d77d(arg0, arg1, arg2) {
|
|
807
|
-
Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
|
|
808
|
-
}
|
|
809
|
-
export function __wbg_push_8ffdcb2063340ba5(arg0, arg1) {
|
|
810
|
-
const ret = arg0.push(arg1);
|
|
811
|
-
return ret;
|
|
812
|
-
}
|
|
813
|
-
export function __wbg_set_6cb8631f80447a67() { return handleError(function (arg0, arg1, arg2) {
|
|
814
|
-
const ret = Reflect.set(arg0, arg1, arg2);
|
|
815
|
-
return ret;
|
|
816
|
-
}, arguments); }
|
|
817
|
-
export function __wbg_set_index_41955224420ba3c6(arg0, arg1, arg2) {
|
|
818
|
-
arg0[arg1 >>> 0] = arg2;
|
|
819
|
-
}
|
|
820
|
-
export function __wbg_set_index_b3244a6c458021e4(arg0, arg1, arg2) {
|
|
821
|
-
arg0[arg1 >>> 0] = arg2;
|
|
822
|
-
}
|
|
823
|
-
export function __wbindgen_cast_0000000000000001(arg0) {
|
|
824
|
-
// Cast intrinsic for `F64 -> Externref`.
|
|
825
|
-
const ret = arg0;
|
|
826
|
-
return ret;
|
|
827
|
-
}
|
|
828
|
-
export function __wbindgen_cast_0000000000000002(arg0, arg1) {
|
|
829
|
-
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
830
|
-
const ret = getStringFromWasm0(arg0, arg1);
|
|
831
|
-
return ret;
|
|
832
|
-
}
|
|
833
185
|
export function __wbindgen_init_externref_table() {
|
|
834
186
|
const table = wasm.__wbindgen_externrefs;
|
|
835
187
|
const offset = table.grow(4);
|
|
@@ -839,31 +191,13 @@ export function __wbindgen_init_externref_table() {
|
|
|
839
191
|
table.set(offset + 2, true);
|
|
840
192
|
table.set(offset + 3, false);
|
|
841
193
|
}
|
|
842
|
-
const
|
|
843
|
-
? { register: () => {}, unregister: () => {} }
|
|
844
|
-
: new FinalizationRegistry(ptr => wasm.__wbg_coloranalysisresult_free(ptr >>> 0, 1));
|
|
845
|
-
const ColorEntryFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
846
|
-
? { register: () => {}, unregister: () => {} }
|
|
847
|
-
: new FinalizationRegistry(ptr => wasm.__wbg_colorentry_free(ptr >>> 0, 1));
|
|
848
|
-
const WasmDownscaleConfigFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
194
|
+
const SmartDownscalerFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
849
195
|
? { register: () => {}, unregister: () => {} }
|
|
850
|
-
: new FinalizationRegistry(ptr => wasm.
|
|
196
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_smartdownscaler_free(ptr >>> 0, 1));
|
|
851
197
|
const WasmDownscaleResultFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
852
198
|
? { register: () => {}, unregister: () => {} }
|
|
853
199
|
: new FinalizationRegistry(ptr => wasm.__wbg_wasmdownscaleresult_free(ptr >>> 0, 1));
|
|
854
200
|
|
|
855
|
-
function addToExternrefTable0(obj) {
|
|
856
|
-
const idx = wasm.__externref_table_alloc();
|
|
857
|
-
wasm.__wbindgen_externrefs.set(idx, obj);
|
|
858
|
-
return idx;
|
|
859
|
-
}
|
|
860
|
-
|
|
861
|
-
function _assertClass(instance, klass) {
|
|
862
|
-
if (!(instance instanceof klass)) {
|
|
863
|
-
throw new Error(`expected instance of ${klass.name}`);
|
|
864
|
-
}
|
|
865
|
-
}
|
|
866
|
-
|
|
867
201
|
function getArrayU8FromWasm0(ptr, len) {
|
|
868
202
|
ptr = ptr >>> 0;
|
|
869
203
|
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
@@ -882,62 +216,13 @@ function getUint8ArrayMemory0() {
|
|
|
882
216
|
return cachedUint8ArrayMemory0;
|
|
883
217
|
}
|
|
884
218
|
|
|
885
|
-
function
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
const idx = addToExternrefTable0(e);
|
|
890
|
-
wasm.__wbindgen_exn_store(idx);
|
|
891
|
-
}
|
|
892
|
-
}
|
|
893
|
-
|
|
894
|
-
function isLikeNone(x) {
|
|
895
|
-
return x === undefined || x === null;
|
|
896
|
-
}
|
|
897
|
-
|
|
898
|
-
function passStringToWasm0(arg, malloc, realloc) {
|
|
899
|
-
if (realloc === undefined) {
|
|
900
|
-
const buf = cachedTextEncoder.encode(arg);
|
|
901
|
-
const ptr = malloc(buf.length, 1) >>> 0;
|
|
902
|
-
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
903
|
-
WASM_VECTOR_LEN = buf.length;
|
|
904
|
-
return ptr;
|
|
905
|
-
}
|
|
906
|
-
|
|
907
|
-
let len = arg.length;
|
|
908
|
-
let ptr = malloc(len, 1) >>> 0;
|
|
909
|
-
|
|
910
|
-
const mem = getUint8ArrayMemory0();
|
|
911
|
-
|
|
912
|
-
let offset = 0;
|
|
913
|
-
|
|
914
|
-
for (; offset < len; offset++) {
|
|
915
|
-
const code = arg.charCodeAt(offset);
|
|
916
|
-
if (code > 0x7F) break;
|
|
917
|
-
mem[ptr + offset] = code;
|
|
918
|
-
}
|
|
919
|
-
if (offset !== len) {
|
|
920
|
-
if (offset !== 0) {
|
|
921
|
-
arg = arg.slice(offset);
|
|
922
|
-
}
|
|
923
|
-
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
924
|
-
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
925
|
-
const ret = cachedTextEncoder.encodeInto(arg, view);
|
|
926
|
-
|
|
927
|
-
offset += ret.written;
|
|
928
|
-
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
929
|
-
}
|
|
930
|
-
|
|
931
|
-
WASM_VECTOR_LEN = offset;
|
|
219
|
+
function passArray8ToWasm0(arg, malloc) {
|
|
220
|
+
const ptr = malloc(arg.length * 1, 1) >>> 0;
|
|
221
|
+
getUint8ArrayMemory0().set(arg, ptr / 1);
|
|
222
|
+
WASM_VECTOR_LEN = arg.length;
|
|
932
223
|
return ptr;
|
|
933
224
|
}
|
|
934
225
|
|
|
935
|
-
function takeFromExternrefTable0(idx) {
|
|
936
|
-
const value = wasm.__wbindgen_externrefs.get(idx);
|
|
937
|
-
wasm.__externref_table_dealloc(idx);
|
|
938
|
-
return value;
|
|
939
|
-
}
|
|
940
|
-
|
|
941
226
|
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
942
227
|
cachedTextDecoder.decode();
|
|
943
228
|
const MAX_SAFARI_DECODE_BYTES = 2146435072;
|
|
@@ -952,19 +237,6 @@ function decodeText(ptr, len) {
|
|
|
952
237
|
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
953
238
|
}
|
|
954
239
|
|
|
955
|
-
const cachedTextEncoder = new TextEncoder();
|
|
956
|
-
|
|
957
|
-
if (!('encodeInto' in cachedTextEncoder)) {
|
|
958
|
-
cachedTextEncoder.encodeInto = function (arg, view) {
|
|
959
|
-
const buf = cachedTextEncoder.encode(arg);
|
|
960
|
-
view.set(buf);
|
|
961
|
-
return {
|
|
962
|
-
read: arg.length,
|
|
963
|
-
written: buf.length
|
|
964
|
-
};
|
|
965
|
-
};
|
|
966
|
-
}
|
|
967
|
-
|
|
968
240
|
let WASM_VECTOR_LEN = 0;
|
|
969
241
|
|
|
970
242
|
|
package/smart_downscaler_bg.wasm
CHANGED
|
Binary file
|