wasm-image-optimization 2.0.8 → 2.0.9
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 +15 -11
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -5,6 +5,10 @@ Built on the Skia rendering engine, it supports animations (GIF/WebP) and modern
|
|
|
5
5
|
|
|
6
6
|
It provides a lightweight, dependency-free solution for generating high-quality visuals and documents across **Node.js**, **Cloudflare Workers**, **Deno**, and **Web Browsers**.
|
|
7
7
|
|
|
8
|
+
> [!TIP]
|
|
9
|
+
> If you need to generate image files from HTML/CSS, please use the [satoru-render](https://www.npmjs.com/package/satoru-render) library.
|
|
10
|
+
|
|
11
|
+
|
|
8
12
|
## Playground
|
|
9
13
|
|
|
10
14
|
https://node-libraries.github.io/wasm-image-optimization/
|
|
@@ -83,17 +87,17 @@ const result = await optimizeImage({
|
|
|
83
87
|
|
|
84
88
|
### Parameters (`OptimizeParams`)
|
|
85
89
|
|
|
86
|
-
| Parameter | Type
|
|
87
|
-
| :-------------- |
|
|
88
|
-
| **`image`** | `Uint8Array`<br>`ArrayBuffer`
|
|
89
|
-
| **`crop`** | `{ x: number, y: number, width: number, height: number }` | -
|
|
90
|
-
| **`width`** | `number`
|
|
91
|
-
| **`height`** | `number`
|
|
92
|
-
| **`fit`** | `contain` <br> `cover` <br> `fill`
|
|
93
|
-
| **`format`** | `string`
|
|
94
|
-
| **`quality`** | `number`
|
|
95
|
-
| **`speed`** | `number`
|
|
96
|
-
| **`animation`** | `boolean`
|
|
90
|
+
| Parameter | Type | Default | Description |
|
|
91
|
+
| :-------------- | :-------------------------------------------------------- | :----------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
92
|
+
| **`image`** | `Uint8Array`<br>`ArrayBuffer` | **Required** | The raw binary data of the image to process. |
|
|
93
|
+
| **`crop`** | `{ x: number, y: number, width: number, height: number }` | - | Rectangular region to crop before resizing. Values are in pixels relative to the original image. |
|
|
94
|
+
| **`width`** | `number` | - | Target width for resizing. If omitted, it's calculated from `height` to maintain aspect ratio. |
|
|
95
|
+
| **`height`** | `number` | - | Target height for resizing. If omitted, it's calculated from `width` to maintain aspect ratio. |
|
|
96
|
+
| **`fit`** | `contain` <br> `cover` <br> `fill` | `'contain'` | Resizing strategy. <br> - `contain`: Fits within bounds (aspect ratio preserved). <br> - `cover`: Fills bounds (may crop). <br> - `fill`: Stretches to match bounds exactly. |
|
|
97
|
+
| **`format`** | `string` | `'webp'` | Output format: `'none'`, `'png'`, `'webp'`, `'jpeg'`, `'avif'`, `'raw'`, `'thumbhash'`. <br> _Note: If `animation: true` and the input is animated, this is forced to `'webp'`._ |
|
|
98
|
+
| **`quality`** | `number` | `100` | Compression quality (0-100). Applies to WebP, JPEG, and AVIF. |
|
|
99
|
+
| **`speed`** | `number` | `6` | Encoding speed (0-10). Primarily used for AVIF. Lower is slower but better compression. |
|
|
100
|
+
| **`animation`** | `boolean` | `false` | If `true`, preserves animation frames (e.g., GIF/animated WebP source). |
|
|
97
101
|
|
|
98
102
|
### Result (`OptimizeResult`)
|
|
99
103
|
|