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 +7 -7
- package/README.md +82 -118
- package/compress_jpeg.d.ts +20 -15
- package/compress_jpeg.js +96 -111
- package/compress_jpeg_bg.wasm +0 -0
- package/package.json +1 -1
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
|
-

|
|
6
|
-
|
|
7
|
-
A
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
-
|
|
12
|
-
-
|
|
13
|
-
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
##
|
|
18
|
-
|
|
19
|
-
-
|
|
20
|
-
-
|
|
21
|
-
-
|
|
22
|
-
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
const
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
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
|
+

|
|
4
|
+

|
|
5
|
+

|
|
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).
|
package/compress_jpeg.d.ts
CHANGED
|
@@ -1,30 +1,35 @@
|
|
|
1
1
|
/* tslint:disable */
|
|
2
2
|
/* eslint-disable */
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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
|
|
17
|
-
readonly
|
|
18
|
-
readonly
|
|
19
|
-
readonly
|
|
20
|
-
readonly
|
|
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
|
-
|
|
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
|
-
|
|
9
|
+
function getClampedArrayU8FromWasm0(ptr, len) {
|
|
10
|
+
ptr = ptr >>> 0;
|
|
11
|
+
return getUint8ClampedArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
12
|
+
}
|
|
6
13
|
|
|
7
|
-
let
|
|
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
|
-
|
|
17
|
-
|
|
18
|
-
|
|
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
|
|
22
|
-
|
|
23
|
-
|
|
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.
|
|
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}
|
|
93
|
+
* @param {number} compression
|
|
35
94
|
* @returns {ImageData}
|
|
36
95
|
*/
|
|
37
|
-
export function compress_jpeg(image_data,
|
|
38
|
-
|
|
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
|
|
101
|
+
return takeFromExternrefTable0(ret[0]);
|
|
45
102
|
}
|
|
46
103
|
|
|
47
|
-
const
|
|
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
|
-
|
|
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.
|
|
141
|
-
|
|
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.
|
|
145
|
-
const ret =
|
|
146
|
-
|
|
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.
|
|
149
|
-
const ret =
|
|
149
|
+
imports.wbg.__wbg_height_93d6779af8295699 = function(arg0) {
|
|
150
|
+
const ret = arg0.height;
|
|
150
151
|
return ret;
|
|
151
152
|
};
|
|
152
|
-
imports.wbg.
|
|
153
|
-
const ret = new
|
|
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.
|
|
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);
|
package/compress_jpeg_bg.wasm
CHANGED
|
Binary file
|