k-centroid-scaler 1.2.4 → 1.3.1

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.
@@ -1,12 +1,11 @@
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
+ export function quantize_perceptual(image_data: Uint8Array, width: number, height: number, num_colors: number, dithering: boolean): ImageResult;
4
5
  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
6
  export function extract_palette(image_data: Uint8Array, num_colors: number): ColorPalette;
7
7
  export function analyze_colors(image_data: Uint8Array, max_colors: number, sort_method: string): ColorAnalysis;
8
8
  export function get_dominant_colors(image_data: Uint8Array, num_colors: number, min_coverage: number): ColorAnalysis;
9
- export function process_image(data: Uint8Array, width: number, height: number, target_width: number, target_height: number, centroids: number, iterations: number): any;
10
9
  export class ColorAnalysis {
11
10
  private constructor();
12
11
  free(): void;
@@ -65,17 +64,16 @@ export interface InitOutput {
65
64
  readonly __wbg_set_coloranalysis_total_pixels: (a: number, b: number) => void;
66
65
  readonly coloranalysis_colors: (a: number, b: number) => void;
67
66
  readonly k_centroid_resize: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => number;
67
+ readonly quantize_perceptual: (a: number, b: number, c: number, d: number, e: number, f: number) => number;
68
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
69
  readonly extract_palette: (a: number, b: number, c: number) => number;
71
70
  readonly analyze_colors: (a: number, b: number, c: number, d: number, e: number) => number;
72
71
  readonly get_dominant_colors: (a: number, b: number, c: number, d: number) => number;
73
- readonly process_image: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => number;
74
72
  readonly __wbg_set_imageresult_width: (a: number, b: number) => void;
75
73
  readonly __wbg_set_imageresult_height: (a: number, b: number) => void;
74
+ readonly __wbg_get_colorpalette_count: (a: number) => number;
76
75
  readonly __wbg_get_imageresult_height: (a: number) => number;
77
76
  readonly __wbg_get_imageresult_width: (a: number) => number;
78
- readonly __wbg_get_colorpalette_count: (a: number) => number;
79
77
  readonly __wbindgen_export_0: (a: number) => void;
80
78
  readonly __wbindgen_export_1: (a: number, b: number) => number;
81
79
  readonly __wbindgen_export_2: (a: number, b: number, c: number, d: number) => number;
@@ -4,8 +4,6 @@ let heap = new Array(128).fill(undefined);
4
4
 
5
5
  heap.push(undefined, null, true, false);
6
6
 
7
- function getObject(idx) { return heap[idx]; }
8
-
9
7
  let heap_next = heap.length;
10
8
 
11
9
  function addHeapObject(obj) {
@@ -17,19 +15,7 @@ function addHeapObject(obj) {
17
15
  return idx;
18
16
  }
19
17
 
20
- let cachedUint8ArrayMemory0 = null;
21
-
22
- function getUint8ArrayMemory0() {
23
- if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
24
- cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
25
- }
26
- return cachedUint8ArrayMemory0;
27
- }
28
-
29
- function getArrayU8FromWasm0(ptr, len) {
30
- ptr = ptr >>> 0;
31
- return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
32
- }
18
+ function getObject(idx) { return heap[idx]; }
33
19
 
34
20
  function handleError(f, args) {
35
21
  try {
@@ -106,6 +92,15 @@ function debugString(val) {
106
92
 
107
93
  let WASM_VECTOR_LEN = 0;
108
94
 
95
+ let cachedUint8ArrayMemory0 = null;
96
+
97
+ function getUint8ArrayMemory0() {
98
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
99
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
100
+ }
101
+ return cachedUint8ArrayMemory0;
102
+ }
103
+
109
104
  const cachedTextEncoder = new TextEncoder();
110
105
 
111
106
  if (!('encodeInto' in cachedTextEncoder)) {
@@ -200,6 +195,11 @@ function takeObject(idx) {
200
195
  return ret;
201
196
  }
202
197
 
198
+ function getArrayU8FromWasm0(ptr, len) {
199
+ ptr = ptr >>> 0;
200
+ return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
201
+ }
202
+
203
203
  function getArrayJsValueFromWasm0(ptr, len) {
204
204
  ptr = ptr >>> 0;
205
205
  const mem = getDataViewMemory0();
@@ -241,10 +241,10 @@ export function k_centroid_resize(image_data, original_width, original_height, t
241
241
  * @param {boolean} dithering
242
242
  * @returns {ImageResult}
243
243
  */
244
- export function quantize_colors_median_cut(image_data, width, height, num_colors, dithering) {
244
+ export function quantize_perceptual(image_data, width, height, num_colors, dithering) {
245
245
  const ptr0 = passArray8ToWasm0(image_data, wasm.__wbindgen_export_1);
246
246
  const len0 = WASM_VECTOR_LEN;
247
- const ret = wasm.quantize_colors_median_cut(ptr0, len0, width, height, num_colors, dithering);
247
+ const ret = wasm.quantize_perceptual(ptr0, len0, width, height, num_colors, dithering);
248
248
  return ImageResult.__wrap(ret);
249
249
  }
250
250
 
@@ -253,14 +253,13 @@ export function quantize_colors_median_cut(image_data, width, height, num_colors
253
253
  * @param {number} width
254
254
  * @param {number} height
255
255
  * @param {number} num_colors
256
- * @param {number} iterations
257
256
  * @param {boolean} dithering
258
257
  * @returns {ImageResult}
259
258
  */
260
- export function quantize_colors_kmeans(image_data, width, height, num_colors, iterations, dithering) {
259
+ export function quantize_colors_median_cut(image_data, width, height, num_colors, dithering) {
261
260
  const ptr0 = passArray8ToWasm0(image_data, wasm.__wbindgen_export_1);
262
261
  const len0 = WASM_VECTOR_LEN;
263
- const ret = wasm.quantize_colors_kmeans(ptr0, len0, width, height, num_colors, iterations, dithering);
262
+ const ret = wasm.quantize_colors_median_cut(ptr0, len0, width, height, num_colors, dithering);
264
263
  return ImageResult.__wrap(ret);
265
264
  }
266
265
 
@@ -304,23 +303,6 @@ export function get_dominant_colors(image_data, num_colors, min_coverage) {
304
303
  return ColorAnalysis.__wrap(ret);
305
304
  }
306
305
 
307
- /**
308
- * @param {Uint8Array} data
309
- * @param {number} width
310
- * @param {number} height
311
- * @param {number} target_width
312
- * @param {number} target_height
313
- * @param {number} centroids
314
- * @param {number} iterations
315
- * @returns {any}
316
- */
317
- export function process_image(data, width, height, target_width, target_height, centroids, iterations) {
318
- const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_export_1);
319
- const len0 = WASM_VECTOR_LEN;
320
- const ret = wasm.process_image(ptr0, len0, width, height, target_width, target_height, centroids, iterations);
321
- return takeObject(ret);
322
- }
323
-
324
306
  const ColorAnalysisFinalization = (typeof FinalizationRegistry === 'undefined')
325
307
  ? { register: () => {}, unregister: () => {} }
326
308
  : new FinalizationRegistry(ptr => wasm.__wbg_coloranalysis_free(ptr >>> 0, 1));
@@ -630,21 +612,10 @@ async function __wbg_load(module, imports) {
630
612
  function __wbg_get_imports() {
631
613
  const imports = {};
632
614
  imports.wbg = {};
633
- imports.wbg.__wbg_length_6bb7e81f9d7713e4 = function(arg0) {
634
- const ret = getObject(arg0).length;
635
- return ret;
636
- };
637
615
  imports.wbg.__wbg_new_19c25a3f2fa63a02 = function() {
638
616
  const ret = new Object();
639
617
  return addHeapObject(ret);
640
618
  };
641
- imports.wbg.__wbg_newwithlength_a167dcc7aaa3ba77 = function(arg0) {
642
- const ret = new Uint8Array(arg0 >>> 0);
643
- return addHeapObject(ret);
644
- };
645
- imports.wbg.__wbg_set_1353b2a5e96bc48c = function(arg0, arg1, arg2) {
646
- getObject(arg0).set(getArrayU8FromWasm0(arg1, arg2));
647
- };
648
619
  imports.wbg.__wbg_set_453345bcda80b89a = function() { return handleError(function (arg0, arg1, arg2) {
649
620
  const ret = Reflect.set(getObject(arg0), getObject(arg1), getObject(arg2));
650
621
  return ret;
Binary file
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "k-centroid-scaler",
3
3
  "type": "module",
4
- "version": "1.2.4",
4
+ "version": "1.3.1",
5
5
  "files": [
6
6
  "k_centroid_scaler_bg.wasm",
7
7
  "k_centroid_scaler.js",