k-centroid-scaler 1.2.1 → 1.2.3
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 +10 -8
- package/k_centroid_scaler.js +78 -32
- package/k_centroid_scaler_bg.wasm +0 -0
- package/package.json +1 -1
package/k_centroid_scaler.d.ts
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
/* tslint:disable */
|
|
2
2
|
/* eslint-disable */
|
|
3
|
-
export function get_dominant_colors(image_data: Uint8Array, num_colors: number, min_coverage: number): ColorAnalysis;
|
|
4
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
|
+
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, iterations: number, dithering: boolean): ImageResult;
|
|
6
|
+
export function extract_palette(image_data: Uint8Array, num_colors: number): ColorPalette;
|
|
7
|
+
export function analyze_colors(image_data: Uint8Array, max_colors: number, sort_method: string): ColorAnalysis;
|
|
8
|
+
export function get_dominant_colors(image_data: Uint8Array, num_colors: number, min_coverage: number): ColorAnalysis;
|
|
5
9
|
export function process_image(data: Uint8Array, width: number, height: number, target_width: number, target_height: number, centroids: number, iterations: number): any;
|
|
6
|
-
export class Centroid {
|
|
7
|
-
private constructor();
|
|
8
|
-
free(): void;
|
|
9
|
-
[Symbol.dispose](): void;
|
|
10
|
-
}
|
|
11
10
|
export class ColorAnalysis {
|
|
12
11
|
private constructor();
|
|
13
12
|
free(): void;
|
|
@@ -65,9 +64,12 @@ export interface InitOutput {
|
|
|
65
64
|
readonly __wbg_get_coloranalysis_total_pixels: (a: number) => number;
|
|
66
65
|
readonly __wbg_set_coloranalysis_total_pixels: (a: number, b: number) => void;
|
|
67
66
|
readonly coloranalysis_colors: (a: number, b: number) => void;
|
|
68
|
-
readonly get_dominant_colors: (a: number, b: number, c: number, d: number) => number;
|
|
69
|
-
readonly __wbg_centroid_free: (a: number, b: number) => void;
|
|
70
67
|
readonly k_centroid_resize: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => number;
|
|
68
|
+
readonly quantize_colors_median_cut: (a: number, b: number, c: number, d: number, e: number, f: number) => number;
|
|
69
|
+
readonly quantize_colors_kmeans: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => number;
|
|
70
|
+
readonly extract_palette: (a: number, b: number, c: number) => number;
|
|
71
|
+
readonly analyze_colors: (a: number, b: number, c: number, d: number, e: number) => number;
|
|
72
|
+
readonly get_dominant_colors: (a: number, b: number, c: number, d: number) => number;
|
|
71
73
|
readonly process_image: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => number;
|
|
72
74
|
readonly __wbg_set_imageresult_width: (a: number, b: number) => void;
|
|
73
75
|
readonly __wbg_set_imageresult_height: (a: number, b: number) => void;
|
package/k_centroid_scaler.js
CHANGED
|
@@ -218,34 +218,92 @@ function passArray8ToWasm0(arg, malloc) {
|
|
|
218
218
|
}
|
|
219
219
|
/**
|
|
220
220
|
* @param {Uint8Array} image_data
|
|
221
|
+
* @param {number} original_width
|
|
222
|
+
* @param {number} original_height
|
|
223
|
+
* @param {number} target_width
|
|
224
|
+
* @param {number} target_height
|
|
225
|
+
* @param {number} centroids
|
|
226
|
+
* @param {number} iterations
|
|
227
|
+
* @returns {ImageResult}
|
|
228
|
+
*/
|
|
229
|
+
export function k_centroid_resize(image_data, original_width, original_height, target_width, target_height, centroids, iterations) {
|
|
230
|
+
const ptr0 = passArray8ToWasm0(image_data, wasm.__wbindgen_export_1);
|
|
231
|
+
const len0 = WASM_VECTOR_LEN;
|
|
232
|
+
const ret = wasm.k_centroid_resize(ptr0, len0, original_width, original_height, target_width, target_height, centroids, iterations);
|
|
233
|
+
return ImageResult.__wrap(ret);
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
/**
|
|
237
|
+
* @param {Uint8Array} image_data
|
|
238
|
+
* @param {number} width
|
|
239
|
+
* @param {number} height
|
|
221
240
|
* @param {number} num_colors
|
|
222
|
-
* @param {
|
|
223
|
-
* @returns {
|
|
241
|
+
* @param {boolean} dithering
|
|
242
|
+
* @returns {ImageResult}
|
|
224
243
|
*/
|
|
225
|
-
export function
|
|
244
|
+
export function quantize_colors_median_cut(image_data, width, height, num_colors, dithering) {
|
|
226
245
|
const ptr0 = passArray8ToWasm0(image_data, wasm.__wbindgen_export_1);
|
|
227
246
|
const len0 = WASM_VECTOR_LEN;
|
|
228
|
-
const ret = wasm.
|
|
229
|
-
return
|
|
247
|
+
const ret = wasm.quantize_colors_median_cut(ptr0, len0, width, height, num_colors, dithering);
|
|
248
|
+
return ImageResult.__wrap(ret);
|
|
230
249
|
}
|
|
231
250
|
|
|
232
251
|
/**
|
|
233
252
|
* @param {Uint8Array} image_data
|
|
234
|
-
* @param {number}
|
|
235
|
-
* @param {number}
|
|
236
|
-
* @param {number}
|
|
237
|
-
* @param {number} target_height
|
|
238
|
-
* @param {number} centroids
|
|
253
|
+
* @param {number} width
|
|
254
|
+
* @param {number} height
|
|
255
|
+
* @param {number} num_colors
|
|
239
256
|
* @param {number} iterations
|
|
257
|
+
* @param {boolean} dithering
|
|
240
258
|
* @returns {ImageResult}
|
|
241
259
|
*/
|
|
242
|
-
export function
|
|
260
|
+
export function quantize_colors_kmeans(image_data, width, height, num_colors, iterations, dithering) {
|
|
243
261
|
const ptr0 = passArray8ToWasm0(image_data, wasm.__wbindgen_export_1);
|
|
244
262
|
const len0 = WASM_VECTOR_LEN;
|
|
245
|
-
const ret = wasm.
|
|
263
|
+
const ret = wasm.quantize_colors_kmeans(ptr0, len0, width, height, num_colors, iterations, dithering);
|
|
246
264
|
return ImageResult.__wrap(ret);
|
|
247
265
|
}
|
|
248
266
|
|
|
267
|
+
/**
|
|
268
|
+
* @param {Uint8Array} image_data
|
|
269
|
+
* @param {number} num_colors
|
|
270
|
+
* @returns {ColorPalette}
|
|
271
|
+
*/
|
|
272
|
+
export function extract_palette(image_data, num_colors) {
|
|
273
|
+
const ptr0 = passArray8ToWasm0(image_data, wasm.__wbindgen_export_1);
|
|
274
|
+
const len0 = WASM_VECTOR_LEN;
|
|
275
|
+
const ret = wasm.extract_palette(ptr0, len0, num_colors);
|
|
276
|
+
return ColorPalette.__wrap(ret);
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
/**
|
|
280
|
+
* @param {Uint8Array} image_data
|
|
281
|
+
* @param {number} max_colors
|
|
282
|
+
* @param {string} sort_method
|
|
283
|
+
* @returns {ColorAnalysis}
|
|
284
|
+
*/
|
|
285
|
+
export function analyze_colors(image_data, max_colors, sort_method) {
|
|
286
|
+
const ptr0 = passArray8ToWasm0(image_data, wasm.__wbindgen_export_1);
|
|
287
|
+
const len0 = WASM_VECTOR_LEN;
|
|
288
|
+
const ptr1 = passStringToWasm0(sort_method, wasm.__wbindgen_export_1, wasm.__wbindgen_export_2);
|
|
289
|
+
const len1 = WASM_VECTOR_LEN;
|
|
290
|
+
const ret = wasm.analyze_colors(ptr0, len0, max_colors, ptr1, len1);
|
|
291
|
+
return ColorAnalysis.__wrap(ret);
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
/**
|
|
295
|
+
* @param {Uint8Array} image_data
|
|
296
|
+
* @param {number} num_colors
|
|
297
|
+
* @param {number} min_coverage
|
|
298
|
+
* @returns {ColorAnalysis}
|
|
299
|
+
*/
|
|
300
|
+
export function get_dominant_colors(image_data, num_colors, min_coverage) {
|
|
301
|
+
const ptr0 = passArray8ToWasm0(image_data, wasm.__wbindgen_export_1);
|
|
302
|
+
const len0 = WASM_VECTOR_LEN;
|
|
303
|
+
const ret = wasm.get_dominant_colors(ptr0, len0, num_colors, min_coverage);
|
|
304
|
+
return ColorAnalysis.__wrap(ret);
|
|
305
|
+
}
|
|
306
|
+
|
|
249
307
|
/**
|
|
250
308
|
* @param {Uint8Array} data
|
|
251
309
|
* @param {number} width
|
|
@@ -263,26 +321,6 @@ export function process_image(data, width, height, target_width, target_height,
|
|
|
263
321
|
return takeObject(ret);
|
|
264
322
|
}
|
|
265
323
|
|
|
266
|
-
const CentroidFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
267
|
-
? { register: () => {}, unregister: () => {} }
|
|
268
|
-
: new FinalizationRegistry(ptr => wasm.__wbg_centroid_free(ptr >>> 0, 1));
|
|
269
|
-
|
|
270
|
-
export class Centroid {
|
|
271
|
-
|
|
272
|
-
__destroy_into_raw() {
|
|
273
|
-
const ptr = this.__wbg_ptr;
|
|
274
|
-
this.__wbg_ptr = 0;
|
|
275
|
-
CentroidFinalization.unregister(this);
|
|
276
|
-
return ptr;
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
free() {
|
|
280
|
-
const ptr = this.__destroy_into_raw();
|
|
281
|
-
wasm.__wbg_centroid_free(ptr, 0);
|
|
282
|
-
}
|
|
283
|
-
}
|
|
284
|
-
if (Symbol.dispose) Centroid.prototype[Symbol.dispose] = Centroid.prototype.free;
|
|
285
|
-
|
|
286
324
|
const ColorAnalysisFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
287
325
|
? { register: () => {}, unregister: () => {} }
|
|
288
326
|
: new FinalizationRegistry(ptr => wasm.__wbg_coloranalysis_free(ptr >>> 0, 1));
|
|
@@ -433,6 +471,14 @@ const ColorPaletteFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
|
433
471
|
|
|
434
472
|
export class ColorPalette {
|
|
435
473
|
|
|
474
|
+
static __wrap(ptr) {
|
|
475
|
+
ptr = ptr >>> 0;
|
|
476
|
+
const obj = Object.create(ColorPalette.prototype);
|
|
477
|
+
obj.__wbg_ptr = ptr;
|
|
478
|
+
ColorPaletteFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
479
|
+
return obj;
|
|
480
|
+
}
|
|
481
|
+
|
|
436
482
|
__destroy_into_raw() {
|
|
437
483
|
const ptr = this.__wbg_ptr;
|
|
438
484
|
this.__wbg_ptr = 0;
|
|
Binary file
|