You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+33-9Lines changed: 33 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -30,10 +30,7 @@ export default {
30
30
};
31
31
```
32
32
33
-
## Options
34
-
35
-
The plugin accepts an array of compressor configuration options, each of which can be either a string or an object. The string can be the name of a built-in compressor and its default configuration enabled.
36
-
Or use the object format configuration and specify the compressor in the `use` field. The remaining fields of the object will be used as compressor configuration options.
33
+
## Default Compressors
37
34
38
35
By default, the plugin will enable `jpeg`, `png`, `ico` image compressors, which are equivalent to the following two examples:
-`pngLossless`: For PNG images with lossless compression.
52
+
-`ico`: For ICO images.
53
+
-`svg`: For SVG images.
54
+
-`avif`: For AVIF images.
55
+
56
+
Only SVG are compressed by `svgo`, other compressors are compressed by `@napi-rs/image`.
57
+
58
+
## Options
59
+
60
+
The plugin accepts an array of compressor configuration options, each of which can be either a string or an object. The string can be the name of a built-in compressor and its default configuration enabled.
61
+
62
+
Or use the object format configuration and specify the compressor in the `use` field. The remaining fields of the object will be used as compressor configuration options.
63
+
48
64
The default configuration can be overridden by specifying a configuration option.
49
65
For example, to allow the jpeg compressor to recognize new extension name and to set the quality of the png compressor.
50
66
51
67
```js
52
68
pluginImageCompress([
69
+
// Options for @napi-rs/image `compressJpeg` method
53
70
{ use:"jpeg", test:/\.(?:jpg|jpeg|jpe)$/ },
71
+
// Options for @napi-rs/image `pngQuantize` method
54
72
{ use:"png", minQuality:50 },
55
-
"ico",
73
+
// Options for @napi-rs/image `avif` method
74
+
{ use:"avif", quality:80 },
75
+
// Options for svgo
76
+
{ use:'svg', floatPrecision:2 }
77
+
// No options yet
78
+
{ use:"ico" },
56
79
]);
57
80
```
58
81
59
-
The default `png` compressor is lossy.
60
-
If you want to replace it with a lossless compressor, you can use the following configuration.
82
+
For more information on compressors, please visit [@napi-rs/image](https://image.napi.rs/docs).
83
+
84
+
## Lossless PNG
85
+
86
+
The default `png` compressor is lossy. If you want to replace it with a lossless compressor, you can use the following configuration.
0 commit comments