compress-jpeg 1.0.5 → 1.1.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/LICENSE CHANGED
@@ -1,7 +1,7 @@
1
- Copyright © 2025 Ganemede Labs
2
-
3
- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
-
5
- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
-
7
- THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1
+ Copyright © 2025 Ganemede Labs
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
+
5
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
+
7
+ THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/README.md CHANGED
@@ -1,118 +1,82 @@
1
- # Compress JPEG
2
-
3
- ![npm](https://img.shields.io/npm/v/compress-jpeg)
4
- ![npm](https://img.shields.io/npm/dw/compress-jpeg)
5
- ![License](https://img.shields.io/npm/l/compress-jpeg)
6
-
7
- A high-performance **WASM** module that simulates JPEG compression artifacts on raw image data, designed to be used easily in JavaScript or TypeScript environments via an npm package.
8
-
9
- ## 📋 Table of Contents
10
-
11
- - [Features](#-features)
12
- - [Installation](#-installation)
13
- - [Usage](#-usage)
14
- - [License](#-license)
15
- - [Contact](#-contact)
16
-
17
- ## Features
18
-
19
- - **Fast** and **portable** through WebAssembly.
20
- - Supports customizable **compression quality**.
21
- - Accepts and returns raw **RGBA pixel data**.
22
- - Pure Rust core with zero dependencies beyond `wasm-bindgen`.
23
-
24
- ## 🔧 Installation
25
-
26
- Install the package via npm:
27
-
28
- ```bash
29
- npm install compress-jpeg
30
- ```
31
-
32
- ## 🚀 Usage
33
-
34
- Here's an example of how to integrate **compress-jpeg** with plain TypeScript in the browser. This snippet shows:
35
-
36
- 1. Loading an image file via an HTML `<input>`.
37
- 2. Drawing it to an off-screen canvas and extracting pixel data.
38
- 3. Passing the data to the WASM function.
39
- 4. Rendering the compressed output back onto a visible canvas.
40
-
41
- ```html
42
- <!-- index.html -->
43
- <!DOCTYPE html>
44
- <html lang="en">
45
- <head>
46
- <meta charset="UTF-8" />
47
- <meta name="viewport" content="width=device-width, initial-scale=1.0" />
48
- <title>WASM JPEG Simulator Demo</title>
49
- </head>
50
- <body>
51
- <!-- File input and canvases -->
52
- <input id="fileInput" type="file" accept="image/*" />
53
- <canvas id="originalCanvas" style="display:none;"></canvas>
54
- <canvas id="processedCanvas"></canvas>
55
-
56
- <script type="module" src="main.ts"></script>
57
- </body>
58
- </html>
59
- ```
60
-
61
- ```typescript
62
- // main.ts
63
- import init, { ImageData as RustImageData, compress_jpeg } from "compress-jpeg";
64
-
65
- const fileInput = document.getElementById("fileInput") as HTMLInputElement;
66
- const originalCanvas = document.getElementById("originalCanvas") as HTMLCanvasElement;
67
- const processedCanvas = document.getElementById("processedCanvas") as HTMLCanvasElement;
68
-
69
- fileInput.addEventListener("change", async () => {
70
- const file = fileInput.files?.[0];
71
- if (!file) return;
72
-
73
- // Initialize the WASM module with an explicit path
74
- await init("/compress_jpeg_bg.wasm");
75
-
76
- // Load image into an off-screen canvas
77
- const img = new Image();
78
- const reader = new FileReader();
79
- reader.onload = () => {
80
- img.src = reader.result as string;
81
- };
82
- reader.readAsDataURL(file);
83
-
84
- img.onload = () => {
85
- originalCanvas.width = img.width;
86
- originalCanvas.height = img.height;
87
- const ctx = originalCanvas.getContext("2d")!;
88
- ctx.drawImage(img, 0, 0);
89
-
90
- // Extract raw pixel data
91
- const browserImageData = ctx.getImageData(0, 0, img.width, img.height);
92
- const rustInput = new RustImageData(
93
- browserImageData.width,
94
- browserImageData.height,
95
- new Uint8ClampedArray(browserImageData.data)
96
- );
97
-
98
- // Simulate JPEG compression at quality=30
99
- const output = compress_jpeg(rustInput, 30);
100
-
101
- // Convert back to browser ImageData
102
- const processedData = new ImageData(output.data(), output.width(), output.height());
103
-
104
- // Draw on visible canvas
105
- processedCanvas.width = output.width();
106
- processedCanvas.height = output.height();
107
- processedCanvas.getContext("2d")!.putImageData(processedData, 0, 0);
108
- };
109
- });
110
- ```
111
-
112
- ## 📜 License
113
-
114
- This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.
115
-
116
- ## 📧 Contact
117
-
118
- For inquiries or more information, you can reach out to us at [ganemedelabs@gmail.com](mailto:ganemedelabs@gmail.com).
1
+ # Compress JPEG
2
+
3
+ ![Version](https://img.shields.io/npm/v/compress-jpeg)
4
+ ![Downloads](https://img.shields.io/npm/dw/compress-jpeg)
5
+ ![License](https://img.shields.io/npm/l/compress-jpeg)
6
+
7
+ A lightweight WebAssembly-powered JPEG-like compressor written in Rust, exposed as an easy-to-use JavaScript API. This package performs a simplified JPEG pipeline entirely in WASM, including:
8
+
9
+ - RGB YCbCr conversion
10
+ - 4:2:0 chroma subsampling
11
+ - 8×8 DCT + quantization
12
+ - Inverse DCT
13
+ - Reconstruction to RGBA
14
+
15
+ The output is not a `.jpg` file, but a visually compressed `ImageData` that simulates JPEG compression artifacts—including blockiness, color loss, and ringing—directly in the browser.
16
+
17
+ ## 📋 Table of Contents
18
+
19
+ - [Features](#-features)
20
+ - [Installation](#-installation)
21
+ - [Usage](#-usage)
22
+ - [License](#-license)
23
+ - [Contact](#-contact)
24
+
25
+ ## ✨ Features
26
+
27
+ - Fast WebAssembly image compression (Rust + wasm-bindgen)
28
+ - Fully controllable compression strength (`0.0 → 1.0`)
29
+ - Implements a full JPEG-style DCT/IDCT pipeline
30
+ - Produces visible JPEG artifacts at higher compression levels
31
+ - Works directly with Canvas `ImageData`
32
+ - Zero dependencies — tiny package size
33
+ - Browser-friendly and easy to use
34
+ - Simple API: `compress_jpeg(imageData: ImageData, compression: number): ImageData`
35
+
36
+ ## 🔧 Installation
37
+
38
+ ```bash
39
+ npm install compress-jpeg
40
+ # or
41
+ yarn add compress-jpeg
42
+ ```
43
+
44
+ ## 🚀 Usage
45
+
46
+ ```typescript
47
+ import init, { compress_jpeg } from "compress-jpeg";
48
+
49
+ async function run() {
50
+ await init(); // initialize WASM module
51
+
52
+ const canvas = document.getElementById("my-canvas") as HTMLCanvasElement;
53
+ const ctx = canvas.getContext("2d")!;
54
+ const imageData = ctx.getImageData(0, 0, canvas.width, canvas.height);
55
+
56
+ /**
57
+ * Compression strength (0.0 → 1.0)
58
+ *
59
+ * - 0.0 = no compression (highest quality)
60
+ * - 1.0 = strongest compression (lowest quality, heavy artifacts)
61
+ *
62
+ * Recommended ranges:
63
+ * - 0.7–1.0 strong blockiness / heavy JPEG artifacts
64
+ * - 0.3–0.7 → medium compression
65
+ * - 0.0–0.3 light compression / near-lossless
66
+ */
67
+ const compression = 0.4;
68
+
69
+ const output = compress_jpeg(imageData, compression);
70
+
71
+ // Draw result onto canvas
72
+ ctx.putImageData(output, 0, 0);
73
+ }
74
+ ```
75
+
76
+ ## 📜 License
77
+
78
+ This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.
79
+
80
+ ## 📧 Contact
81
+
82
+ For inquiries or more information, you can reach out to us at [ganemedelabs@gmail.com](mailto:ganemedelabs@gmail.com).
@@ -1,30 +1,35 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
- export function compress_jpeg(image_data: ImageData, quality: number): ImageData;
4
- export class ImageData {
5
- free(): void;
6
- constructor(width: number, height: number, data: Uint8ClampedArray);
7
- width(): number;
8
- height(): number;
9
- data(): Uint8ClampedArray;
10
- }
3
+
4
+ /**
5
+ * Compress an ImageData using a simplified JPEG-style pipeline.
6
+ *
7
+ * **Parameters:**
8
+ * - `image_data`: The RGBA ImageData to compress.
9
+ * - `compression`: A value from 0.0–1.0:
10
+ * - 0.0 = no compression (highest quality)
11
+ * - 1.0 = strongest compression (lowest quality)
12
+ *
13
+ * **Returns:**
14
+ * A new `ImageData` object containing the visually compressed pixels.
15
+ */
16
+ export function compress_jpeg(image_data: ImageData, compression: number): ImageData;
11
17
 
12
18
  export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
13
19
 
14
20
  export interface InitOutput {
15
21
  readonly memory: WebAssembly.Memory;
16
- readonly __wbg_imagedata_free: (a: number, b: number) => void;
17
- readonly imagedata_new: (a: number, b: number, c: any) => number;
18
- readonly imagedata_width: (a: number) => number;
19
- readonly imagedata_height: (a: number) => number;
20
- readonly imagedata_data: (a: number) => any;
21
- readonly compress_jpeg: (a: number, b: number) => [number, number, number];
22
- readonly __wbindgen_export_0: WebAssembly.Table;
22
+ readonly compress_jpeg: (a: any, b: number) => [number, number, number];
23
+ readonly __wbindgen_malloc: (a: number, b: number) => number;
24
+ readonly __wbindgen_exn_store: (a: number) => void;
25
+ readonly __externref_table_alloc: () => number;
26
+ readonly __wbindgen_externrefs: WebAssembly.Table;
23
27
  readonly __externref_table_dealloc: (a: number) => void;
24
28
  readonly __wbindgen_start: () => void;
25
29
  }
26
30
 
27
31
  export type SyncInitInput = BufferSource | WebAssembly.Module;
32
+
28
33
  /**
29
34
  * Instantiates the given `module`, which can either be bytes or
30
35
  * a precompiled `WebAssembly.Module`.
package/compress_jpeg.js CHANGED
@@ -1,11 +1,30 @@
1
1
  let wasm;
2
2
 
3
- const cachedTextDecoder = (typeof TextDecoder !== 'undefined' ? new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }) : { decode: () => { throw Error('TextDecoder not available') } } );
3
+ function addToExternrefTable0(obj) {
4
+ const idx = wasm.__externref_table_alloc();
5
+ wasm.__wbindgen_externrefs.set(idx, obj);
6
+ return idx;
7
+ }
4
8
 
5
- if (typeof TextDecoder !== 'undefined') { cachedTextDecoder.decode(); };
9
+ function getClampedArrayU8FromWasm0(ptr, len) {
10
+ ptr = ptr >>> 0;
11
+ return getUint8ClampedArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
12
+ }
6
13
 
7
- let cachedUint8ArrayMemory0 = null;
14
+ let cachedDataViewMemory0 = null;
15
+ function getDataViewMemory0() {
16
+ if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
17
+ cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
18
+ }
19
+ return cachedDataViewMemory0;
20
+ }
8
21
 
22
+ function getStringFromWasm0(ptr, len) {
23
+ ptr = ptr >>> 0;
24
+ return decodeText(ptr, len);
25
+ }
26
+
27
+ let cachedUint8ArrayMemory0 = null;
9
28
  function getUint8ArrayMemory0() {
10
29
  if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
11
30
  cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
@@ -13,104 +32,86 @@ function getUint8ArrayMemory0() {
13
32
  return cachedUint8ArrayMemory0;
14
33
  }
15
34
 
16
- function getStringFromWasm0(ptr, len) {
17
- ptr = ptr >>> 0;
18
- return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
35
+ let cachedUint8ClampedArrayMemory0 = null;
36
+ function getUint8ClampedArrayMemory0() {
37
+ if (cachedUint8ClampedArrayMemory0 === null || cachedUint8ClampedArrayMemory0.byteLength === 0) {
38
+ cachedUint8ClampedArrayMemory0 = new Uint8ClampedArray(wasm.memory.buffer);
39
+ }
40
+ return cachedUint8ClampedArrayMemory0;
19
41
  }
20
42
 
21
- function _assertClass(instance, klass) {
22
- if (!(instance instanceof klass)) {
23
- throw new Error(`expected instance of ${klass.name}`);
43
+ function handleError(f, args) {
44
+ try {
45
+ return f.apply(this, args);
46
+ } catch (e) {
47
+ const idx = addToExternrefTable0(e);
48
+ wasm.__wbindgen_exn_store(idx);
24
49
  }
25
50
  }
26
51
 
52
+ function passArray8ToWasm0(arg, malloc) {
53
+ const ptr = malloc(arg.length * 1, 1) >>> 0;
54
+ getUint8ArrayMemory0().set(arg, ptr / 1);
55
+ WASM_VECTOR_LEN = arg.length;
56
+ return ptr;
57
+ }
58
+
27
59
  function takeFromExternrefTable0(idx) {
28
- const value = wasm.__wbindgen_export_0.get(idx);
60
+ const value = wasm.__wbindgen_externrefs.get(idx);
29
61
  wasm.__externref_table_dealloc(idx);
30
62
  return value;
31
63
  }
64
+
65
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
66
+ cachedTextDecoder.decode();
67
+ const MAX_SAFARI_DECODE_BYTES = 2146435072;
68
+ let numBytesDecoded = 0;
69
+ function decodeText(ptr, len) {
70
+ numBytesDecoded += len;
71
+ if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
72
+ cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
73
+ cachedTextDecoder.decode();
74
+ numBytesDecoded = len;
75
+ }
76
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
77
+ }
78
+
79
+ let WASM_VECTOR_LEN = 0;
80
+
32
81
  /**
82
+ * Compress an ImageData using a simplified JPEG-style pipeline.
83
+ *
84
+ * **Parameters:**
85
+ * - `image_data`: The RGBA ImageData to compress.
86
+ * - `compression`: A value from 0.0–1.0:
87
+ * - 0.0 = no compression (highest quality)
88
+ * - 1.0 = strongest compression (lowest quality)
89
+ *
90
+ * **Returns:**
91
+ * A new `ImageData` object containing the visually compressed pixels.
33
92
  * @param {ImageData} image_data
34
- * @param {number} quality
93
+ * @param {number} compression
35
94
  * @returns {ImageData}
36
95
  */
37
- export function compress_jpeg(image_data, quality) {
38
- _assertClass(image_data, ImageData);
39
- var ptr0 = image_data.__destroy_into_raw();
40
- const ret = wasm.compress_jpeg(ptr0, quality);
96
+ export function compress_jpeg(image_data, compression) {
97
+ const ret = wasm.compress_jpeg(image_data, compression);
41
98
  if (ret[2]) {
42
99
  throw takeFromExternrefTable0(ret[1]);
43
100
  }
44
- return ImageData.__wrap(ret[0]);
101
+ return takeFromExternrefTable0(ret[0]);
45
102
  }
46
103
 
47
- const ImageDataFinalization = (typeof FinalizationRegistry === 'undefined')
48
- ? { register: () => {}, unregister: () => {} }
49
- : new FinalizationRegistry(ptr => wasm.__wbg_imagedata_free(ptr >>> 0, 1));
50
-
51
- export class ImageData {
52
-
53
- static __wrap(ptr) {
54
- ptr = ptr >>> 0;
55
- const obj = Object.create(ImageData.prototype);
56
- obj.__wbg_ptr = ptr;
57
- ImageDataFinalization.register(obj, obj.__wbg_ptr, obj);
58
- return obj;
59
- }
60
-
61
- __destroy_into_raw() {
62
- const ptr = this.__wbg_ptr;
63
- this.__wbg_ptr = 0;
64
- ImageDataFinalization.unregister(this);
65
- return ptr;
66
- }
67
-
68
- free() {
69
- const ptr = this.__destroy_into_raw();
70
- wasm.__wbg_imagedata_free(ptr, 0);
71
- }
72
- /**
73
- * @param {number} width
74
- * @param {number} height
75
- * @param {Uint8ClampedArray} data
76
- */
77
- constructor(width, height, data) {
78
- const ret = wasm.imagedata_new(width, height, data);
79
- this.__wbg_ptr = ret >>> 0;
80
- ImageDataFinalization.register(this, this.__wbg_ptr, this);
81
- return this;
82
- }
83
- /**
84
- * @returns {number}
85
- */
86
- width() {
87
- const ret = wasm.imagedata_width(this.__wbg_ptr);
88
- return ret >>> 0;
89
- }
90
- /**
91
- * @returns {number}
92
- */
93
- height() {
94
- const ret = wasm.imagedata_height(this.__wbg_ptr);
95
- return ret >>> 0;
96
- }
97
- /**
98
- * @returns {Uint8ClampedArray}
99
- */
100
- data() {
101
- const ret = wasm.imagedata_data(this.__wbg_ptr);
102
- return ret;
103
- }
104
- }
104
+ const EXPECTED_RESPONSE_TYPES = new Set(['basic', 'cors', 'default']);
105
105
 
106
106
  async function __wbg_load(module, imports) {
107
107
  if (typeof Response === 'function' && module instanceof Response) {
108
108
  if (typeof WebAssembly.instantiateStreaming === 'function') {
109
109
  try {
110
110
  return await WebAssembly.instantiateStreaming(module, imports);
111
-
112
111
  } catch (e) {
113
- if (module.headers.get('Content-Type') != 'application/wasm') {
112
+ const validResponse = module.ok && EXPECTED_RESPONSE_TYPES.has(module.type);
113
+
114
+ if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
114
115
  console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e);
115
116
 
116
117
  } else {
@@ -121,13 +122,11 @@ async function __wbg_load(module, imports) {
121
122
 
122
123
  const bytes = await module.arrayBuffer();
123
124
  return await WebAssembly.instantiate(bytes, imports);
124
-
125
125
  } else {
126
126
  const instance = await WebAssembly.instantiate(module, imports);
127
127
 
128
128
  if (instance instanceof WebAssembly.Instance) {
129
129
  return { instance, module };
130
-
131
130
  } else {
132
131
  return instance;
133
132
  }
@@ -137,54 +136,47 @@ async function __wbg_load(module, imports) {
137
136
  function __wbg_get_imports() {
138
137
  const imports = {};
139
138
  imports.wbg = {};
140
- imports.wbg.__wbg_buffer_609cc3eee51ed158 = function(arg0) {
141
- const ret = arg0.buffer;
142
- return ret;
139
+ imports.wbg.__wbg___wbindgen_throw_dd24417ed36fc46e = function(arg0, arg1) {
140
+ throw new Error(getStringFromWasm0(arg0, arg1));
143
141
  };
144
- imports.wbg.__wbg_length_238152a0aedbb6e7 = function(arg0) {
145
- const ret = arg0.length;
146
- return ret;
142
+ imports.wbg.__wbg_data_83b2a9a09dd4ab39 = function(arg0, arg1) {
143
+ const ret = arg1.data;
144
+ const ptr1 = passArray8ToWasm0(ret, wasm.__wbindgen_malloc);
145
+ const len1 = WASM_VECTOR_LEN;
146
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
147
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
147
148
  };
148
- imports.wbg.__wbg_new_7a91e41fe43b3c92 = function(arg0) {
149
- const ret = new Uint8ClampedArray(arg0);
149
+ imports.wbg.__wbg_height_93d6779af8295699 = function(arg0) {
150
+ const ret = arg0.height;
150
151
  return ret;
151
152
  };
152
- imports.wbg.__wbg_newwithbyteoffsetandlength_6d34787141015158 = function(arg0, arg1, arg2) {
153
- const ret = new Uint8ClampedArray(arg0, arg1 >>> 0, arg2 >>> 0);
153
+ imports.wbg.__wbg_new_with_u8_clamped_array_and_sh_5ac77cce3f6497ff = function() { return handleError(function (arg0, arg1, arg2, arg3) {
154
+ const ret = new ImageData(getClampedArrayU8FromWasm0(arg0, arg1), arg2 >>> 0, arg3 >>> 0);
155
+ return ret;
156
+ }, arguments) };
157
+ imports.wbg.__wbg_width_73a6511a2370c184 = function(arg0) {
158
+ const ret = arg0.width;
154
159
  return ret;
155
- };
156
- imports.wbg.__wbg_set_6775f73144c2ef27 = function(arg0, arg1, arg2) {
157
- arg0.set(arg1, arg2 >>> 0);
158
160
  };
159
161
  imports.wbg.__wbindgen_init_externref_table = function() {
160
- const table = wasm.__wbindgen_export_0;
162
+ const table = wasm.__wbindgen_externrefs;
161
163
  const offset = table.grow(4);
162
164
  table.set(0, undefined);
163
165
  table.set(offset + 0, undefined);
164
166
  table.set(offset + 1, null);
165
167
  table.set(offset + 2, true);
166
168
  table.set(offset + 3, false);
167
- ;
168
- };
169
- imports.wbg.__wbindgen_memory = function() {
170
- const ret = wasm.memory;
171
- return ret;
172
- };
173
- imports.wbg.__wbindgen_throw = function(arg0, arg1) {
174
- throw new Error(getStringFromWasm0(arg0, arg1));
175
169
  };
176
170
 
177
171
  return imports;
178
172
  }
179
173
 
180
- function __wbg_init_memory(imports, memory) {
181
-
182
- }
183
-
184
174
  function __wbg_finalize_init(instance, module) {
185
175
  wasm = instance.exports;
186
176
  __wbg_init.__wbindgen_wasm_module = module;
177
+ cachedDataViewMemory0 = null;
187
178
  cachedUint8ArrayMemory0 = null;
179
+ cachedUint8ClampedArrayMemory0 = null;
188
180
 
189
181
 
190
182
  wasm.__wbindgen_start();
@@ -204,15 +196,10 @@ function initSync(module) {
204
196
  }
205
197
 
206
198
  const imports = __wbg_get_imports();
207
-
208
- __wbg_init_memory(imports);
209
-
210
199
  if (!(module instanceof WebAssembly.Module)) {
211
200
  module = new WebAssembly.Module(module);
212
201
  }
213
-
214
202
  const instance = new WebAssembly.Instance(module, imports);
215
-
216
203
  return __wbg_finalize_init(instance, module);
217
204
  }
218
205
 
@@ -237,8 +224,6 @@ async function __wbg_init(module_or_path) {
237
224
  module_or_path = fetch(module_or_path);
238
225
  }
239
226
 
240
- __wbg_init_memory(imports);
241
-
242
227
  const { instance, module } = await __wbg_load(await module_or_path, imports);
243
228
 
244
229
  return __wbg_finalize_init(instance, module);
Binary file
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "compress-jpeg",
3
3
  "type": "module",
4
4
  "description": "A simple JPEG compression library for WebAssembly",
5
- "version": "1.0.5",
5
+ "version": "1.1.0",
6
6
  "license": "MIT",
7
7
  "files": [
8
8
  "compress_jpeg_bg.wasm",