smart-downscaler 0.5.0 → 0.6.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.
package/README.md CHANGED
@@ -4,7 +4,7 @@ A high-performance Rust library for intelligent image downscaling with pixel art
4
4
 
5
5
  **Available as a native Rust library and WebAssembly module for browser/Node.js.**
6
6
 
7
- [![Version](https://img.shields.io/badge/version-0.5.0-blue.svg)]()
7
+ [![Version](https://img.shields.io/badge/version-0.6.0-blue.svg)]()
8
8
  [![License](https://img.shields.io/badge/license-MIT-green.svg)]()
9
9
 
10
10
  ---
@@ -35,6 +35,7 @@ A high-performance Rust library for intelligent image downscaling with pixel art
35
35
  | **Edge-Aware Processing** | Sobel/Scharr detection preserves boundaries |
36
36
  | **Spatial Coherence** | Neighbor and region voting for smooth results |
37
37
  | **K-Centroid Tile Logic** | Advanced dominant color extraction per tile |
38
+ | **Rare-Color Preservation** | Saliency weighting + slot reservation keeps small, important colors (lips, eyes) |
38
39
  | **Performance Preprocessing** | Resolution capping and color pre-quantization |
39
40
  | **WebAssembly Support** | Full browser compatibility with near-native speed |
40
41
 
@@ -46,7 +47,7 @@ A high-performance Rust library for intelligent image downscaling with pixel art
46
47
 
47
48
  ```toml
48
49
  [dependencies]
49
- smart-downscaler = "0.5.0"
50
+ smart-downscaler = "0.6.0"
50
51
  ```
51
52
 
52
53
  ### WebAssembly (npm)
@@ -59,7 +60,7 @@ npm install smart-downscaler
59
60
 
60
61
  ```html
61
62
  <script type="module">
62
- import init, { downscale_rgba, WasmDownscaleConfig } from 'https://unpkg.com/smart-downscaler@0.5.0/smart_downscaler.js';
63
+ import init, { downscale_rgba, WasmDownscaleConfig } from 'https://unpkg.com/smart-downscaler@0.6.0/smart_downscaler.js';
63
64
  </script>
64
65
  ```
65
66
 
@@ -168,8 +169,12 @@ println!("Palette: {} colors", result.palette.len());
168
169
  | `max_resolution_mp` | `f32` | `1.6` | `0.0-10.0` | Resolution cap in megapixels (0 = disabled) |
169
170
  | `max_color_preprocess` | `usize` | `16384` | `0-65536` | Pre-quantization limit (0 = disabled) |
170
171
  | **Tile Processing** |||||
171
- | `k_centroid` | `usize` | `1` | `1`, `2`, `3` | Tile color extraction mode |
172
+ | `k_centroid` | `usize` | `1` | `1`, `2`, `3`, `4` | Tile color extraction mode |
172
173
  | `k_centroid_iterations` | `usize` | `0` | `0-10` | K-Means iterations for tile color |
174
+ | **Rare-Color Preservation** |||||
175
+ | `color_rarity` | `f32` | `0.0` | `0.0-1.0` | Damps frequency vote so large flat areas stop dominating (`0`=area, `1`=`count^0.5`) |
176
+ | `detail_boost` | `f32` | `0.0` | `0.0-2.0` | Boosts colors in detail-rich regions via a local-contrast saliency map (`0`=off) |
177
+ | `reserve_colors` | `usize` | `0` | `0 - palette_size` | Reserve N palette slots for distinct, important, under-represented source colors (`0`=off) |
173
178
 
174
179
  ---
175
180
 
@@ -224,6 +229,9 @@ Controls how each source tile is reduced to a single representative color:
224
229
  | **Average** | `1` | Simple weighted average of all pixels | Smooth gradients, noise reduction |
225
230
  | **Dominant** | `2` | K-Means (k=2), uses largest cluster | Sharp edges, foreground/background separation |
226
231
  | **Foremost** | `3` | K-Means (k=3), finer dominant detection | Complex textures, detailed sprites |
232
+ | **Salient** | `4` | K-Means (k=2), keeps a distinctly-more-chromatic minority | Thin colorful features (lips, eyes, makeup) |
233
+
234
+ > **Note:** Mode `2` (Dominant) snaps a mixed tile to its *larger* cluster, which discards thin minority colors — a tile that is 60% skin / 40% lip becomes pure skin. For faces and other artwork with small colorful features, prefer mode `4`, which keeps the colorful minority when it is non-trivial (≥22% of the tile) and clearly more chromatic than the majority.
227
235
 
228
236
  ```javascript
229
237
  // Mode 1: Average (default) - smooth results
@@ -237,6 +245,10 @@ config.k_centroid_iterations = 2;
237
245
  // Mode 3: Foremost - detailed preservation
238
246
  config.k_centroid = 3;
239
247
  config.k_centroid_iterations = 3;
248
+
249
+ // Mode 4: Salient - preserve thin colorful features (lips, eyes)
250
+ config.k_centroid = 4;
251
+ config.k_centroid_iterations = 2;
240
252
  ```
241
253
 
242
254
  ---
@@ -447,7 +459,7 @@ const dist = color_distance(255, 0, 0, 0, 255, 0); // Red vs Green
447
459
  Get library version.
448
460
 
449
461
  ```javascript
450
- console.log(version()); // "0.5.0"
462
+ console.log(version()); // "0.6.0"
451
463
  ```
452
464
 
453
465
  ---
@@ -496,18 +508,59 @@ const exact = WasmDownscaleConfig.exact_colors();
496
508
 
497
509
  ### Preset Comparison
498
510
 
499
- | Preset | Palette | K-Means | Segmentation | K-Centroid | Speed |
500
- |--------|---------|---------|--------------|------------|-------|
501
- | `fast()` | 16 | 3 | none | 1 (avg) | ⚡⚡⚡ |
502
- | `default` | 16 | 5 | hierarchy_fast | 1 (avg) | ⚡⚡ |
503
- | `vibrant()` | 24 | 8 | hierarchy_fast | 2 (dom) | ⚡ |
504
- | `quality()` | 32 | 10 | hierarchy | 2 (dom) | 🐢 |
505
- | `exact_colors()` | 16 | 0 | hierarchy_fast | 1 (avg) | ⚡⚡ |
511
+ | Preset | Palette | K-Means | Segmentation | K-Centroid | Rare-Color¹ | Speed |
512
+ |--------|---------|---------|--------------|------------|-------------|-------|
513
+ | `fast()` | 16 | 3 | none | 1 (avg) | off | ⚡⚡⚡ |
514
+ | `default` | 16 | 5 | hierarchy_fast | 1 (avg) | off | ⚡⚡ |
515
+ | `vibrant()` | 24 | 8 | hierarchy_fast | 2 (dom) | on (3 slots) | ⚡ |
516
+ | `quality()` | 32 | 10 | hierarchy | 2 (dom) | on (4 slots) | 🐢 |
517
+ | `exact_colors()` | 16 | 0 | hierarchy_fast | 1 (avg) | off | ⚡⚡ |
518
+
519
+ ¹ `vibrant()` and `quality()` enable `reserve_colors` + `detail_boost` + `color_rarity`. For the strongest thin-feature retention (faces), additionally set `k_centroid = 4`.
506
520
 
507
521
  ---
508
522
 
509
523
  ## Advanced Usage
510
524
 
525
+ ### Preserving Rare / Important Colors
526
+
527
+ Palette extraction is **area-weighted**: a color that covers a large region gets
528
+ many "votes", so small but perceptually important colors — lips, eyes, a logo,
529
+ a colored highlight — are easily merged into the dominant tones (e.g. lips into
530
+ skin) at low palette sizes (16–64). Three knobs counteract this:
531
+
532
+ | Knob | What it does | When to raise it |
533
+ |------|--------------|------------------|
534
+ | `reserve_colors` | **Hard guarantee.** Reserves N slots, filled with exact source colors that are far from the rest of the palette *and* important. The most reliable fix. | Always, for portraits/artwork with small features. ~`palette_size / 8`. |
535
+ | `detail_boost` | Weights extraction toward colors in **detail-rich regions** using a local-contrast saliency map (measured at the downscale radius, so it targets features thin enough to be averaged away — and picks their *clean* interior color, not muddy edge blends). | When the important color sits in a high-detail area (most facial features). `0.8–1.0`. |
536
+ | `color_rarity` | Damps the frequency vote (`count^p`, `p = 1 − 0.5·rarity`) so large flat regions stop monopolizing the palette. | Mild assist alongside the above. `0.3–0.4`. |
537
+
538
+ Pair these with `k_centroid = 4` (Salient), which stops the *tile* stage from
539
+ discarding the same minority colors. A correct palette is wasted if a 60% skin /
540
+ 40% lip tile is still snapped to skin.
541
+
542
+ ```javascript
543
+ // Recommended for faces / portraits at 16–64 colors
544
+ const config = new WasmDownscaleConfig();
545
+ config.palette_size = 32;
546
+ config.palette_strategy = 'oklab'; // honors color_rarity / detail_boost in median-cut
547
+ config.k_centroid = 4; // salient tile color (keep colorful minorities)
548
+ config.k_centroid_iterations = 2;
549
+ config.reserve_colors = 4; // ~palette_size / 8 — the guarantee
550
+ config.detail_boost = 0.9; // saliency targeting
551
+ config.color_rarity = 0.35; // frequency damping
552
+ config.neighbor_weight = 0.18; // lower = less erosion of thin features
553
+ ```
554
+
555
+ > **Trade-off:** at very small palettes, reserving slots for rare colors costs
556
+ > some gradient smoothness elsewhere. Scale `reserve_colors` with `palette_size`
557
+ > (16→2, 32→4, 64→8) and lean on it harder at the high end.
558
+ >
559
+ > **Strategy note:** `bitmask` ignores frequency weights during its initial
560
+ > split, so with `bitmask` only `reserve_colors` is active. Use `oklab` (or
561
+ > `saturation`) if you also want `color_rarity` / `detail_boost` to shape the
562
+ > main palette.
563
+
511
564
  ### Custom Palette Workflow
512
565
 
513
566
  ```javascript
@@ -705,7 +758,7 @@ smart-downscaler input.png --extract-palette palette.hex -c 16
705
758
  | `--colors` | `-c` | `16` | Palette size |
706
759
  | `--strategy` | `-s` | `oklab` | Palette strategy |
707
760
  | `--segmentation` | | `hierarchy_fast` | Segmentation method |
708
- | `--k-centroid` | | `1` | Tile color mode |
761
+ | `--k-centroid` | | `1` | Tile color mode (1=avg, 2=dominant, 3=foremost, 4=salient) |
709
762
  | `--k-centroid-iterations` | | `0` | Tile refinement |
710
763
  | `--no-refinement` | | false | Disable two-pass |
711
764
  | `--preset` | `-p` | | Use preset (fast/quality/vibrant) |
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "Pixagram"
6
6
  ],
7
7
  "description": "Intelligent pixel art downscaler with region-aware color quantization",
8
- "version": "0.5.0",
8
+ "version": "0.6.1",
9
9
  "license": "MIT",
10
10
  "repository": {
11
11
  "type": "git",
@@ -14,13 +14,11 @@
14
14
  "files": [
15
15
  "smart_downscaler_bg.wasm",
16
16
  "smart_downscaler.js",
17
- "smart_downscaler_bg.js",
18
17
  "smart_downscaler.d.ts"
19
18
  ],
20
19
  "main": "smart_downscaler.js",
21
20
  "types": "smart_downscaler.d.ts",
22
21
  "sideEffects": [
23
- "./smart_downscaler.js",
24
22
  "./snippets/*"
25
23
  ],
26
24
  "keywords": [
@@ -1,34 +1,18 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
3
 
4
- /**
5
- * Result of color analysis
6
- */
7
4
  export class ColorAnalysisResult {
8
5
  private constructor();
9
6
  free(): void;
10
7
  [Symbol.dispose](): void;
11
- /**
12
- * Get color at index
13
- */
14
8
  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
9
  get_colors_flat(): Uint8Array;
20
- /**
21
- * Get colors as JSON-compatible array
22
- */
23
10
  to_json(): any;
24
11
  readonly color_count: number;
25
12
  readonly success: boolean;
26
13
  readonly total_pixels: number;
27
14
  }
28
15
 
29
- /**
30
- * A single color entry with statistics
31
- */
32
16
  export class ColorEntry {
33
17
  private constructor();
34
18
  free(): void;
@@ -49,16 +33,18 @@ export class WasmDownscaleConfig {
49
33
  constructor();
50
34
  static quality(): WasmDownscaleConfig;
51
35
  static vibrant(): WasmDownscaleConfig;
52
- edge_weight: number;
53
- hierarchy_min_size: number;
54
- hierarchy_threshold: number;
55
36
  /**
56
- * Iterations for tile centroid
37
+ * Rare-color preservation: 0.0 = pure area weighting, 1.0 = strong (count^0.5).
57
38
  */
58
- k_centroid_iterations: number;
39
+ color_rarity: number;
59
40
  /**
60
- * K-Means centroid mode (1=Avg, 2=Dom, 3=Foremost)
41
+ * Detail-color boost via local-contrast saliency. 0.0 = off.
61
42
  */
43
+ detail_boost: number;
44
+ edge_weight: number;
45
+ hierarchy_min_size: number;
46
+ hierarchy_threshold: number;
47
+ k_centroid_iterations: number;
62
48
  k_centroid: number;
63
49
  kmeans_iterations: number;
64
50
  max_color_preprocess: number;
@@ -67,6 +53,10 @@ export class WasmDownscaleConfig {
67
53
  palette_size: number;
68
54
  refinement_iterations: number;
69
55
  region_weight: number;
56
+ /**
57
+ * Reserve N palette slots for distinct, important, under-represented colors. 0 = off.
58
+ */
59
+ reserve_colors: number;
70
60
  slic_compactness: number;
71
61
  slic_superpixels: number;
72
62
  two_pass_refinement: boolean;
@@ -88,78 +78,159 @@ export class WasmDownscaleResult {
88
78
  }
89
79
 
90
80
  /**
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
81
+ * Analyze colors FIX: uses HashMap<u32, usize> for O(1) lookup (was O(n) linear scan)
101
82
  */
102
83
  export function analyze_colors(image_data: Uint8Array, max_colors: number, sort_method: string): ColorAnalysisResult;
103
84
 
104
- /**
105
- * Compute perceptual color distance between two RGB colors
106
- */
107
85
  export function color_distance(r1: number, g1: number, b1: number, r2: number, g2: number, b2: number): number;
108
86
 
109
87
  export function downscale(image_data: Uint8Array, width: number, height: number, target_width: number, target_height: number, config?: WasmDownscaleConfig | null): WasmDownscaleResult;
110
88
 
111
89
  export function downscale_rgba(image_data: Uint8ClampedArray, width: number, height: number, target_width: number, target_height: number, config?: WasmDownscaleConfig | null): WasmDownscaleResult;
112
90
 
113
- /**
114
- * Simple downscale function with minimal parameters
115
- */
116
91
  export function downscale_simple(image_data: Uint8Array, width: number, height: number, target_width: number, target_height: number, num_colors: number): WasmDownscaleResult;
117
92
 
118
93
  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
94
 
120
- /**
121
- * Extract a color palette from an image without downscaling
122
- */
123
95
  export function extract_palette_from_image(image_data: Uint8Array, _width: number, _height: number, num_colors: number, kmeans_iterations: number, strategy?: string | null): Uint8Array;
124
96
 
125
- /**
126
- * Get chroma (saturation) of an RGB color
127
- */
128
97
  export function get_chroma(r: number, g: number, b: number): number;
129
98
 
130
- /**
131
- * Get lightness of an RGB color in Oklab space
132
- */
133
99
  export function get_lightness(r: number, g: number, b: number): number;
134
100
 
135
- /**
136
- * Get available palette strategies
137
- */
138
101
  export function get_palette_strategies(): Array<any>;
139
102
 
140
103
  export function init(): void;
141
104
 
142
- /**
143
- * Log a message to the browser console (for debugging)
144
- */
145
105
  export function log(message: string): void;
146
106
 
147
- /**
148
- * Convert Oklab to RGB (utility function for JS)
149
- */
150
107
  export function oklab_to_rgb(l: number, a: number, b: number): Uint8Array;
151
108
 
152
109
  /**
153
- * Quantize an image to a specific palette without resizing
110
+ * Quantize to palette FIX: compute Oklab once per pixel (was twice)
154
111
  */
155
112
  export function quantize_to_palette(image_data: Uint8Array, width: number, height: number, palette_data: Uint8Array): WasmDownscaleResult;
156
113
 
114
+ export function rgb_to_oklab(r: number, g: number, b: number): Float32Array;
115
+
116
+ export function version(): string;
117
+
118
+ export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
119
+
120
+ export interface InitOutput {
121
+ readonly memory: WebAssembly.Memory;
122
+ readonly __wbg_coloranalysisresult_free: (a: number, b: number) => void;
123
+ readonly __wbg_colorentry_free: (a: number, b: number) => void;
124
+ readonly __wbg_get_wasmdownscaleconfig_color_rarity: (a: number) => number;
125
+ readonly __wbg_get_wasmdownscaleconfig_detail_boost: (a: number) => number;
126
+ readonly __wbg_get_wasmdownscaleconfig_edge_weight: (a: number) => number;
127
+ readonly __wbg_get_wasmdownscaleconfig_hierarchy_min_size: (a: number) => number;
128
+ readonly __wbg_get_wasmdownscaleconfig_hierarchy_threshold: (a: number) => number;
129
+ readonly __wbg_get_wasmdownscaleconfig_k_centroid: (a: number) => number;
130
+ readonly __wbg_get_wasmdownscaleconfig_k_centroid_iterations: (a: number) => number;
131
+ readonly __wbg_get_wasmdownscaleconfig_kmeans_iterations: (a: number) => number;
132
+ readonly __wbg_get_wasmdownscaleconfig_max_color_preprocess: (a: number) => number;
133
+ readonly __wbg_get_wasmdownscaleconfig_max_resolution_mp: (a: number) => number;
134
+ readonly __wbg_get_wasmdownscaleconfig_neighbor_weight: (a: number) => number;
135
+ readonly __wbg_get_wasmdownscaleconfig_palette_size: (a: number) => number;
136
+ readonly __wbg_get_wasmdownscaleconfig_refinement_iterations: (a: number) => number;
137
+ readonly __wbg_get_wasmdownscaleconfig_region_weight: (a: number) => number;
138
+ readonly __wbg_get_wasmdownscaleconfig_reserve_colors: (a: number) => number;
139
+ readonly __wbg_get_wasmdownscaleconfig_slic_compactness: (a: number) => number;
140
+ readonly __wbg_get_wasmdownscaleconfig_slic_superpixels: (a: number) => number;
141
+ readonly __wbg_get_wasmdownscaleconfig_two_pass_refinement: (a: number) => number;
142
+ readonly __wbg_set_wasmdownscaleconfig_color_rarity: (a: number, b: number) => void;
143
+ readonly __wbg_set_wasmdownscaleconfig_detail_boost: (a: number, b: number) => void;
144
+ readonly __wbg_set_wasmdownscaleconfig_edge_weight: (a: number, b: number) => void;
145
+ readonly __wbg_set_wasmdownscaleconfig_hierarchy_min_size: (a: number, b: number) => void;
146
+ readonly __wbg_set_wasmdownscaleconfig_hierarchy_threshold: (a: number, b: number) => void;
147
+ readonly __wbg_set_wasmdownscaleconfig_k_centroid: (a: number, b: number) => void;
148
+ readonly __wbg_set_wasmdownscaleconfig_k_centroid_iterations: (a: number, b: number) => void;
149
+ readonly __wbg_set_wasmdownscaleconfig_kmeans_iterations: (a: number, b: number) => void;
150
+ readonly __wbg_set_wasmdownscaleconfig_max_color_preprocess: (a: number, b: number) => void;
151
+ readonly __wbg_set_wasmdownscaleconfig_max_resolution_mp: (a: number, b: number) => void;
152
+ readonly __wbg_set_wasmdownscaleconfig_neighbor_weight: (a: number, b: number) => void;
153
+ readonly __wbg_set_wasmdownscaleconfig_palette_size: (a: number, b: number) => void;
154
+ readonly __wbg_set_wasmdownscaleconfig_refinement_iterations: (a: number, b: number) => void;
155
+ readonly __wbg_set_wasmdownscaleconfig_region_weight: (a: number, b: number) => void;
156
+ readonly __wbg_set_wasmdownscaleconfig_reserve_colors: (a: number, b: number) => void;
157
+ readonly __wbg_set_wasmdownscaleconfig_slic_compactness: (a: number, b: number) => void;
158
+ readonly __wbg_set_wasmdownscaleconfig_slic_superpixels: (a: number, b: number) => void;
159
+ readonly __wbg_set_wasmdownscaleconfig_two_pass_refinement: (a: number, b: number) => void;
160
+ readonly __wbg_wasmdownscaleconfig_free: (a: number, b: number) => void;
161
+ readonly __wbg_wasmdownscaleresult_free: (a: number, b: number) => void;
162
+ readonly analyze_colors: (a: any, b: number, c: number, d: number) => [number, number, number];
163
+ readonly color_distance: (a: number, b: number, c: number, d: number, e: number, f: number) => number;
164
+ readonly coloranalysisresult_color_count: (a: number) => number;
165
+ readonly coloranalysisresult_get_color: (a: number, b: number) => number;
166
+ readonly coloranalysisresult_get_colors_flat: (a: number) => any;
167
+ readonly coloranalysisresult_success: (a: number) => number;
168
+ readonly coloranalysisresult_to_json: (a: number) => [number, number, number];
169
+ readonly coloranalysisresult_total_pixels: (a: number) => number;
170
+ readonly colorentry_b: (a: number) => number;
171
+ readonly colorentry_count: (a: number) => number;
172
+ readonly colorentry_g: (a: number) => number;
173
+ readonly colorentry_hex: (a: number) => [number, number];
174
+ readonly colorentry_percentage: (a: number) => number;
175
+ readonly colorentry_r: (a: number) => number;
176
+ readonly downscale: (a: any, b: number, c: number, d: number, e: number, f: number) => [number, number, number];
177
+ readonly downscale_rgba: (a: any, b: number, c: number, d: number, e: number, f: number) => [number, number, number];
178
+ readonly downscale_simple: (a: any, b: number, c: number, d: number, e: number, f: number) => [number, number, number];
179
+ readonly downscale_with_palette: (a: any, b: number, c: number, d: number, e: number, f: any, g: number) => [number, number, number];
180
+ readonly extract_palette_from_image: (a: any, b: number, c: number, d: number, e: number, f: number, g: number) => [number, number, number];
181
+ readonly get_chroma: (a: number, b: number, c: number) => number;
182
+ readonly get_lightness: (a: number, b: number, c: number) => number;
183
+ readonly get_palette_strategies: () => any;
184
+ readonly init: () => void;
185
+ readonly log: (a: number, b: number) => void;
186
+ readonly oklab_to_rgb: (a: number, b: number, c: number) => any;
187
+ readonly quantize_to_palette: (a: any, b: number, c: number, d: any) => [number, number, number];
188
+ readonly rgb_to_oklab: (a: number, b: number, c: number) => any;
189
+ readonly version: () => [number, number];
190
+ readonly wasmdownscaleconfig_exact_colors: () => number;
191
+ readonly wasmdownscaleconfig_fast: () => number;
192
+ readonly wasmdownscaleconfig_new: () => number;
193
+ readonly wasmdownscaleconfig_palette_strategy: (a: number) => [number, number];
194
+ readonly wasmdownscaleconfig_quality: () => number;
195
+ readonly wasmdownscaleconfig_segmentation_method: (a: number) => [number, number];
196
+ readonly wasmdownscaleconfig_set_palette_strategy: (a: number, b: number, c: number) => void;
197
+ readonly wasmdownscaleconfig_set_segmentation_method: (a: number, b: number, c: number) => void;
198
+ readonly wasmdownscaleconfig_vibrant: () => number;
199
+ readonly wasmdownscaleresult_data: (a: number) => any;
200
+ readonly wasmdownscaleresult_height: (a: number) => number;
201
+ readonly wasmdownscaleresult_indices: (a: number) => any;
202
+ readonly wasmdownscaleresult_palette: (a: number) => any;
203
+ readonly wasmdownscaleresult_palette_size: (a: number) => number;
204
+ readonly wasmdownscaleresult_rgb_data: (a: number) => any;
205
+ readonly wasmdownscaleresult_width: (a: number) => number;
206
+ readonly __wbindgen_exn_store: (a: number) => void;
207
+ readonly __externref_table_alloc: () => number;
208
+ readonly __wbindgen_externrefs: WebAssembly.Table;
209
+ readonly __wbindgen_malloc: (a: number, b: number) => number;
210
+ readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
211
+ readonly __externref_table_dealloc: (a: number) => void;
212
+ readonly __wbindgen_free: (a: number, b: number, c: number) => void;
213
+ readonly __wbindgen_start: () => void;
214
+ }
215
+
216
+ export type SyncInitInput = BufferSource | WebAssembly.Module;
217
+
157
218
  /**
158
- * Convert RGB to Oklab (utility function for JS)
219
+ * Instantiates the given `module`, which can either be bytes or
220
+ * a precompiled `WebAssembly.Module`.
221
+ *
222
+ * @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
223
+ *
224
+ * @returns {InitOutput}
159
225
  */
160
- export function rgb_to_oklab(r: number, g: number, b: number): Float32Array;
226
+ export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
161
227
 
162
228
  /**
163
- * Get library version
229
+ * If `module_or_path` is {RequestInfo} or {URL}, makes a request and
230
+ * for everything else, calls `WebAssembly.instantiate` directly.
231
+ *
232
+ * @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
233
+ *
234
+ * @returns {Promise<InitOutput>}
164
235
  */
165
- export function version(): string;
236
+ export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;