k-centroid-scaler 1.2.3 → 1.3.0
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/k_centroid_scaler.d.ts +19 -2
- package/k_centroid_scaler.js +55 -6
- package/k_centroid_scaler_bg.wasm +0 -0
- package/package.json +1 -1
package/k_centroid_scaler.d.ts
CHANGED
|
@@ -1,9 +1,23 @@
|
|
|
1
1
|
/* tslint:disable */
|
|
2
2
|
/* eslint-disable */
|
|
3
3
|
export function k_centroid_resize(image_data: Uint8Array, original_width: number, original_height: number, target_width: number, target_height: number, centroids: number, iterations: number): ImageResult;
|
|
4
|
+
/**
|
|
5
|
+
* Stage 1: Fast quantization to 256 colors or less using k-means++ in RGB space
|
|
6
|
+
* This stage is fast and doesn't alter tints significantly
|
|
7
|
+
*/
|
|
8
|
+
export function quantize_colors_stage1(image_data: Uint8Array, width: number, height: number, target_colors: number): ImageResult;
|
|
9
|
+
/**
|
|
10
|
+
* Stage 2: Perceptually accurate quantization using CIELAB color space
|
|
11
|
+
* Best for final color reduction where human perception matters
|
|
12
|
+
*/
|
|
13
|
+
export function quantize_colors_stage2_lab(image_data: Uint8Array, width: number, height: number, target_colors: number, dithering: boolean): ImageResult;
|
|
14
|
+
/**
|
|
15
|
+
* Complete two-stage quantization: Stage 1 (fast) -> Stage 2 (perceptual)
|
|
16
|
+
*/
|
|
17
|
+
export function quantize_colors_two_stage(image_data: Uint8Array, width: number, height: number, target_colors: number, dithering: boolean): ImageResult;
|
|
4
18
|
export function quantize_colors_median_cut(image_data: Uint8Array, width: number, height: number, num_colors: number, dithering: boolean): ImageResult;
|
|
5
|
-
export function quantize_colors_kmeans(image_data: Uint8Array, width: number, height: number, num_colors: number,
|
|
6
|
-
export function extract_palette(image_data: Uint8Array,
|
|
19
|
+
export function quantize_colors_kmeans(image_data: Uint8Array, width: number, height: number, num_colors: number, _iterations: number, dithering: boolean): ImageResult;
|
|
20
|
+
export function extract_palette(image_data: Uint8Array, max_colors: number): ColorPalette;
|
|
7
21
|
export function analyze_colors(image_data: Uint8Array, max_colors: number, sort_method: string): ColorAnalysis;
|
|
8
22
|
export function get_dominant_colors(image_data: Uint8Array, num_colors: number, min_coverage: number): ColorAnalysis;
|
|
9
23
|
export function process_image(data: Uint8Array, width: number, height: number, target_width: number, target_height: number, centroids: number, iterations: number): any;
|
|
@@ -65,6 +79,8 @@ export interface InitOutput {
|
|
|
65
79
|
readonly __wbg_set_coloranalysis_total_pixels: (a: number, b: number) => void;
|
|
66
80
|
readonly coloranalysis_colors: (a: number, b: number) => void;
|
|
67
81
|
readonly k_centroid_resize: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => number;
|
|
82
|
+
readonly quantize_colors_stage1: (a: number, b: number, c: number, d: number, e: number) => number;
|
|
83
|
+
readonly quantize_colors_stage2_lab: (a: number, b: number, c: number, d: number, e: number, f: number) => number;
|
|
68
84
|
readonly quantize_colors_median_cut: (a: number, b: number, c: number, d: number, e: number, f: number) => number;
|
|
69
85
|
readonly quantize_colors_kmeans: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => number;
|
|
70
86
|
readonly extract_palette: (a: number, b: number, c: number) => number;
|
|
@@ -73,6 +89,7 @@ export interface InitOutput {
|
|
|
73
89
|
readonly process_image: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => number;
|
|
74
90
|
readonly __wbg_set_imageresult_width: (a: number, b: number) => void;
|
|
75
91
|
readonly __wbg_set_imageresult_height: (a: number, b: number) => void;
|
|
92
|
+
readonly quantize_colors_two_stage: (a: number, b: number, c: number, d: number, e: number, f: number) => number;
|
|
76
93
|
readonly __wbg_get_colorpalette_count: (a: number) => number;
|
|
77
94
|
readonly __wbg_get_imageresult_height: (a: number) => number;
|
|
78
95
|
readonly __wbg_get_imageresult_width: (a: number) => number;
|
package/k_centroid_scaler.js
CHANGED
|
@@ -233,6 +233,55 @@ export function k_centroid_resize(image_data, original_width, original_height, t
|
|
|
233
233
|
return ImageResult.__wrap(ret);
|
|
234
234
|
}
|
|
235
235
|
|
|
236
|
+
/**
|
|
237
|
+
* Stage 1: Fast quantization to 256 colors or less using k-means++ in RGB space
|
|
238
|
+
* This stage is fast and doesn't alter tints significantly
|
|
239
|
+
* @param {Uint8Array} image_data
|
|
240
|
+
* @param {number} width
|
|
241
|
+
* @param {number} height
|
|
242
|
+
* @param {number} target_colors
|
|
243
|
+
* @returns {ImageResult}
|
|
244
|
+
*/
|
|
245
|
+
export function quantize_colors_stage1(image_data, width, height, target_colors) {
|
|
246
|
+
const ptr0 = passArray8ToWasm0(image_data, wasm.__wbindgen_export_1);
|
|
247
|
+
const len0 = WASM_VECTOR_LEN;
|
|
248
|
+
const ret = wasm.quantize_colors_stage1(ptr0, len0, width, height, target_colors);
|
|
249
|
+
return ImageResult.__wrap(ret);
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
/**
|
|
253
|
+
* Stage 2: Perceptually accurate quantization using CIELAB color space
|
|
254
|
+
* Best for final color reduction where human perception matters
|
|
255
|
+
* @param {Uint8Array} image_data
|
|
256
|
+
* @param {number} width
|
|
257
|
+
* @param {number} height
|
|
258
|
+
* @param {number} target_colors
|
|
259
|
+
* @param {boolean} dithering
|
|
260
|
+
* @returns {ImageResult}
|
|
261
|
+
*/
|
|
262
|
+
export function quantize_colors_stage2_lab(image_data, width, height, target_colors, dithering) {
|
|
263
|
+
const ptr0 = passArray8ToWasm0(image_data, wasm.__wbindgen_export_1);
|
|
264
|
+
const len0 = WASM_VECTOR_LEN;
|
|
265
|
+
const ret = wasm.quantize_colors_stage2_lab(ptr0, len0, width, height, target_colors, dithering);
|
|
266
|
+
return ImageResult.__wrap(ret);
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
/**
|
|
270
|
+
* Complete two-stage quantization: Stage 1 (fast) -> Stage 2 (perceptual)
|
|
271
|
+
* @param {Uint8Array} image_data
|
|
272
|
+
* @param {number} width
|
|
273
|
+
* @param {number} height
|
|
274
|
+
* @param {number} target_colors
|
|
275
|
+
* @param {boolean} dithering
|
|
276
|
+
* @returns {ImageResult}
|
|
277
|
+
*/
|
|
278
|
+
export function quantize_colors_two_stage(image_data, width, height, target_colors, dithering) {
|
|
279
|
+
const ptr0 = passArray8ToWasm0(image_data, wasm.__wbindgen_export_1);
|
|
280
|
+
const len0 = WASM_VECTOR_LEN;
|
|
281
|
+
const ret = wasm.quantize_colors_median_cut(ptr0, len0, width, height, target_colors, dithering);
|
|
282
|
+
return ImageResult.__wrap(ret);
|
|
283
|
+
}
|
|
284
|
+
|
|
236
285
|
/**
|
|
237
286
|
* @param {Uint8Array} image_data
|
|
238
287
|
* @param {number} width
|
|
@@ -253,26 +302,26 @@ export function quantize_colors_median_cut(image_data, width, height, num_colors
|
|
|
253
302
|
* @param {number} width
|
|
254
303
|
* @param {number} height
|
|
255
304
|
* @param {number} num_colors
|
|
256
|
-
* @param {number}
|
|
305
|
+
* @param {number} _iterations
|
|
257
306
|
* @param {boolean} dithering
|
|
258
307
|
* @returns {ImageResult}
|
|
259
308
|
*/
|
|
260
|
-
export function quantize_colors_kmeans(image_data, width, height, num_colors,
|
|
309
|
+
export function quantize_colors_kmeans(image_data, width, height, num_colors, _iterations, dithering) {
|
|
261
310
|
const ptr0 = passArray8ToWasm0(image_data, wasm.__wbindgen_export_1);
|
|
262
311
|
const len0 = WASM_VECTOR_LEN;
|
|
263
|
-
const ret = wasm.quantize_colors_kmeans(ptr0, len0, width, height, num_colors,
|
|
312
|
+
const ret = wasm.quantize_colors_kmeans(ptr0, len0, width, height, num_colors, _iterations, dithering);
|
|
264
313
|
return ImageResult.__wrap(ret);
|
|
265
314
|
}
|
|
266
315
|
|
|
267
316
|
/**
|
|
268
317
|
* @param {Uint8Array} image_data
|
|
269
|
-
* @param {number}
|
|
318
|
+
* @param {number} max_colors
|
|
270
319
|
* @returns {ColorPalette}
|
|
271
320
|
*/
|
|
272
|
-
export function extract_palette(image_data,
|
|
321
|
+
export function extract_palette(image_data, max_colors) {
|
|
273
322
|
const ptr0 = passArray8ToWasm0(image_data, wasm.__wbindgen_export_1);
|
|
274
323
|
const len0 = WASM_VECTOR_LEN;
|
|
275
|
-
const ret = wasm.extract_palette(ptr0, len0,
|
|
324
|
+
const ret = wasm.extract_palette(ptr0, len0, max_colors);
|
|
276
325
|
return ColorPalette.__wrap(ret);
|
|
277
326
|
}
|
|
278
327
|
|
|
Binary file
|