wasm-image-optimization 1.2.22 → 1.2.24
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 +65 -74
- package/dist/cjs/types/index.d.ts +1 -1
- package/dist/cjs/types/index.js.map +1 -1
- package/dist/esm/libImage.wasm +0 -0
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,77 +1,45 @@
|
|
|
1
1
|
# wasm-image-optimization
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
WebAssembly is used to provide image transformation functionality.
|
|
4
4
|
|
|
5
|
-
-
|
|
6
|
-
`import { optimizeImage } from 'wasm-image-optimization';`
|
|
7
|
-
- Next.js (Webpack)
|
|
8
|
-
`import { optimizeImage } from 'wasm-image-optimization/next';`
|
|
9
|
-
- ESM (import base) & Deno Deploy
|
|
10
|
-
`import { optimizeImage } from 'wasm-image-optimization';`
|
|
11
|
-
- Node.js
|
|
12
|
-
`import { optimizeImage } from 'wasm-image-optimization';`
|
|
13
|
-
- Node.js(Multi thread)
|
|
14
|
-
`import { optimizeImage } from 'wasm-image-optimization/node-worker';`
|
|
15
|
-
- Vite (Browser)
|
|
16
|
-
`import { optimizeImage } from 'wasm-image-optimization/vite';`
|
|
17
|
-
- Web Worker (Browser) Multi process
|
|
18
|
-
`import { optimizeImage } from 'wasm-image-optimization/web-worker';`
|
|
19
|
-
|
|
20
|
-
## Samples
|
|
21
|
-
|
|
22
|
-
https://github.com/SoraKumo001/wasm-image-optimization-samples
|
|
5
|
+
- Frontend
|
|
23
6
|
|
|
24
|
-
|
|
7
|
+
- Next.js (Multithreading support)
|
|
8
|
+
- React Router (Multithreading support)
|
|
25
9
|
|
|
26
|
-
|
|
10
|
+
- Backend
|
|
27
11
|
|
|
28
|
-
|
|
12
|
+
- Cloudflare Workers
|
|
13
|
+
- Deno Deploy
|
|
14
|
+
- Node.js (Multithreading support)
|
|
29
15
|
|
|
30
|
-
|
|
16
|
+
- Convert
|
|
17
|
+
- source format
|
|
18
|
+
- svg
|
|
19
|
+
- jpeg (EXIF orientation is supported)
|
|
20
|
+
- png
|
|
21
|
+
- webp
|
|
22
|
+
- avif
|
|
23
|
+
- output format
|
|
24
|
+
- jpeg
|
|
25
|
+
- png
|
|
26
|
+
- webp
|
|
27
|
+
- avif (default)
|
|
31
28
|
|
|
32
|
-
|
|
29
|
+
## Example
|
|
33
30
|
|
|
34
|
-
|
|
31
|
+
https://next-image-convert.vercel.app/
|
|
32
|
+

|
|
35
33
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
Sample for image optimization on Deno.
|
|
39
|
-
|
|
40
|
-
### node-image-convert
|
|
41
|
-
|
|
42
|
-
Sample for converting image formats on Node.js.
|
|
43
|
-
Single-threaded and multi-threaded operation can be selected.
|
|
44
|
-
|
|
45
|
-
## WebWorker on Vite
|
|
46
|
-
|
|
47
|
-
- vite.config.ts
|
|
48
|
-
|
|
49
|
-
```ts
|
|
50
|
-
import wasmImageOptimizationPlugin from "wasm-image-optimization/vite-plugin";
|
|
51
|
-
|
|
52
|
-
export default defineConfig(() => ({
|
|
53
|
-
plugins: [wasmImageOptimizationPlugin()],
|
|
54
|
-
}));
|
|
55
|
-
```
|
|
56
|
-
|
|
57
|
-
## Next.js on Backend API
|
|
34
|
+
## Functions
|
|
58
35
|
|
|
59
36
|
```ts
|
|
60
|
-
import { optimizeImage } from "wasm-image-optimization";
|
|
61
|
-
…
|
|
62
|
-
export const runtime = "edge";
|
|
63
|
-
```
|
|
64
|
-
|
|
65
|
-
## function
|
|
66
|
-
|
|
67
|
-
```ts
|
|
68
|
-
|
|
69
37
|
optimizeImage({
|
|
70
38
|
image: ArrayBuffer,
|
|
71
39
|
width?: number,
|
|
72
40
|
height?:number,
|
|
73
41
|
quality?: number, // quality: 1-100
|
|
74
|
-
format?: "png" | "jpeg" | "avif" | "webp"}
|
|
42
|
+
format?: "png" | "jpeg" | "avif" | "webp" | "none"}
|
|
75
43
|
speed?: number // avif-speed: 0-10 (Slow-Fast, default: 6)
|
|
76
44
|
):
|
|
77
45
|
Promise<
|
|
@@ -82,26 +50,49 @@ optimizeImageExt({
|
|
|
82
50
|
width?: number,
|
|
83
51
|
height?:number,
|
|
84
52
|
quality?: number,
|
|
85
|
-
format?: "png" | "jpeg" | "avif" | "webp"}
|
|
53
|
+
format?: "png" | "jpeg" | "avif" | "webp" | "none"}
|
|
86
54
|
speed?: number // avif-speed: 0-10 (Slow-Fast, default: 6)
|
|
87
55
|
):
|
|
88
56
|
Promise<{
|
|
89
|
-
data: Uint8Array
|
|
90
|
-
originalWidth: number
|
|
91
|
-
originalHeight: number
|
|
92
|
-
width: number
|
|
93
|
-
height: number
|
|
57
|
+
data: Uint8Array,
|
|
58
|
+
originalWidth: number,
|
|
59
|
+
originalHeight: number,
|
|
60
|
+
width: number,
|
|
61
|
+
height: number}>
|
|
62
|
+
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## WebWorker on Vite
|
|
66
|
+
|
|
67
|
+
To use Vite, the following settings are required
|
|
68
|
+
|
|
69
|
+
- vite.config.ts
|
|
94
70
|
|
|
71
|
+
```ts
|
|
72
|
+
import wasmImageOptimizationPlugin from "wasm-image-optimization/vite-plugin";
|
|
73
|
+
|
|
74
|
+
export default defineConfig(() => ({
|
|
75
|
+
plugins: [wasmImageOptimizationPlugin()],
|
|
76
|
+
}));
|
|
95
77
|
```
|
|
96
78
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
-
|
|
101
|
-
|
|
102
|
-
-
|
|
103
|
-
-
|
|
104
|
-
-
|
|
105
|
-
|
|
106
|
-
-
|
|
107
|
-
|
|
79
|
+
## Supported Environments
|
|
80
|
+
|
|
81
|
+
- Cloudflare workers
|
|
82
|
+
`import { optimizeImage } from 'wasm-image-optimization';`
|
|
83
|
+
- Next.js (Webpack)
|
|
84
|
+
`import { optimizeImage } from 'wasm-image-optimization/next';`
|
|
85
|
+
- ESM (import base) & Deno Deploy
|
|
86
|
+
`import { optimizeImage } from 'wasm-image-optimization';`
|
|
87
|
+
- Node.js
|
|
88
|
+
`import { optimizeImage } from 'wasm-image-optimization';`
|
|
89
|
+
- Node.js(Multi thread)
|
|
90
|
+
`import { optimizeImage } from 'wasm-image-optimization/node-worker';`
|
|
91
|
+
- Vite (Browser)
|
|
92
|
+
`import { optimizeImage } from 'wasm-image-optimization/vite';`
|
|
93
|
+
- Web Worker (Browser) Multi process
|
|
94
|
+
`import { optimizeImage } from 'wasm-image-optimization/web-worker';`
|
|
95
|
+
|
|
96
|
+
## Samples
|
|
97
|
+
|
|
98
|
+
https://github.com/SoraKumo001/wasm-image-optimization-samples
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/types/index.ts"],"names":[],"mappings":"","sourcesContent":["export type OptimizeResult = {\n data: Uint8Array;\n originalWidth: number;\n originalHeight: number;\n width: number;\n height: number;\n};\n\nexport type OptimizeParams = {\n image: BufferSource | string; // The input image data\n width?: number; // The desired output width (optional)\n height?: number; // The desired output height (optional)\n quality?: number; // The desired output quality (0-100, optional)\n format?: \"jpeg\" | \"png\" | \"webp\" | \"avif\"; // The desired output format (optional)\n speed?: number; // The desired speed (0-10, Slow-Fast, Optional)\n};\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/types/index.ts"],"names":[],"mappings":"","sourcesContent":["export type OptimizeResult = {\n data: Uint8Array;\n originalWidth: number;\n originalHeight: number;\n width: number;\n height: number;\n};\n\nexport type OptimizeParams = {\n image: BufferSource | string; // The input image data\n width?: number; // The desired output width (optional)\n height?: number; // The desired output height (optional)\n quality?: number; // The desired output quality (0-100, optional)\n format?: \"jpeg\" | \"png\" | \"webp\" | \"avif\" | \"none\"; // The desired output format (optional)\n speed?: number; // The desired speed (0-10, Slow-Fast, Optional)\n};\n"]}
|
package/dist/esm/libImage.wasm
CHANGED
|
Binary file
|
package/dist/types/index.d.ts
CHANGED
package/dist/types/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"","sourcesContent":["export type OptimizeResult = {\n data: Uint8Array;\n originalWidth: number;\n originalHeight: number;\n width: number;\n height: number;\n};\n\nexport type OptimizeParams = {\n image: BufferSource | string; // The input image data\n width?: number; // The desired output width (optional)\n height?: number; // The desired output height (optional)\n quality?: number; // The desired output quality (0-100, optional)\n format?: \"jpeg\" | \"png\" | \"webp\" | \"avif\"; // The desired output format (optional)\n speed?: number; // The desired speed (0-10, Slow-Fast, Optional)\n};\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"","sourcesContent":["export type OptimizeResult = {\n data: Uint8Array;\n originalWidth: number;\n originalHeight: number;\n width: number;\n height: number;\n};\n\nexport type OptimizeParams = {\n image: BufferSource | string; // The input image data\n width?: number; // The desired output width (optional)\n height?: number; // The desired output height (optional)\n quality?: number; // The desired output quality (0-100, optional)\n format?: \"jpeg\" | \"png\" | \"webp\" | \"avif\" | \"none\"; // The desired output format (optional)\n speed?: number; // The desired speed (0-10, Slow-Fast, Optional)\n};\n"]}
|
package/package.json
CHANGED