UNPKG

3.2 kBMarkdownView Raw
1# imagemin-mozjpeg [![Build Status](https://travis-ci.org/imagemin/imagemin-mozjpeg.svg?branch=master)](https://travis-ci.org/imagemin/imagemin-mozjpeg) [![Build status](https://ci.appveyor.com/api/projects/status/uuh7yi48erf4ykyo?svg=true)](https://ci.appveyor.com/project/ShinnosukeWatanabe/imagemin-mozjpeg)
2
3> [Imagemin](https://github.com/imagemin/imagemin) plugin for [mozjpeg](https://github.com/mozilla/mozjpeg)
4
5
6## Install
7
8```
9$ npm install imagemin-mozjpeg
10```
11
12
13## Usage
14
15```js
16const imagemin = require('imagemin');
17const imageminMozjpeg = require('imagemin-mozjpeg');
18
19(async () => {
20 await imagemin(['images/*.jpg'], 'build/images', {
21 use: [
22 imageminMozjpeg()
23 ]
24 });
25
26 console.log('Images optimized');
27})();
28```
29
30
31## API
32
33### imageminMozjpeg([options])(buffer)
34
35Returns a `Promise<Buffer>`.
36
37#### options
38
39##### quality
40
41Type: `number`
42
43Compression quality, in range `0` (worst) to `100` (perfect).
44
45##### progressive
46
47Type: `boolean`<br>
48Default: `true`
49
50`false` creates baseline JPEG file.
51
52##### targa
53
54Type: `boolean`<br>
55Default: `false`
56
57Input file is Targa format (usually not needed).
58
59##### revert
60
61Type: `boolean`<br>
62Default: `false`
63
64Revert to standard defaults instead of mozjpeg defaults.
65
66##### fastCrush
67
68Type: `boolean`<br>
69Default: `false`
70
71Disable progressive scan optimization.
72
73##### dcScanOpt
74
75Type: `number`<br>
76Default: `1`
77
78Set DC scan optimization mode.
79
80- `0` One scan for all components
81- `1` One scan per component
82- `2` Optimize between one scan for all components and one scan for 1st component plus one scan for remaining components
83
84##### trellis
85
86Type: `boolean`<br>
87Default: `true`
88
89[Trellis optimization](https://en.wikipedia.org/wiki/Trellis_quantization).
90
91##### trellisDC
92
93Type: `boolean`<br>
94Default: `true`
95
96Trellis optimization of DC coefficients.
97
98##### tune
99
100Type: `string`<br>
101Default: `hvs-psnr`
102
103Set Trellis optimization method. Available methods: `psnr`, `hvs-psnr`, `ssim`, `ms-ssim`
104
105##### overshoot
106
107Type: `boolean`<br>
108Default: `true`
109
110Black-on-white deringing via overshoot.
111
112##### arithmetic
113
114Type: `boolean`<br>
115Default: `false`
116
117Use [arithmetic coding](https://en.wikipedia.org/wiki/Arithmetic_coding).
118
119##### dct
120
121Type: `string`<br>
122Default: `int`
123
124Set [DCT](https://en.wikipedia.org/wiki/Discrete_cosine_transform) method:
125
126- `int` Use integer DCT
127- `fast` Use fast integer DCT (less accurate)
128- `float` Use floating-point DCT
129
130##### quantBaseline
131
132Type: `boolean`<br>
133Default: `false`
134
135Use 8-bit quantization table entries for baseline JPEG compatibility.
136
137##### quantTable
138
139Type: `number`
140
141Use predefined quantization table.
142
143- `0` JPEG Annex K
144- `1` Flat
145- `2` Custom, tuned for MS-SSIM
146- `3` ImageMagick table by N. Robidoux
147- `4` Custom, tuned for PSNR-HVS
148- `5` Table from paper by Klein, Silverstein and Carney
149
150##### smooth
151
152Type: `number`
153
154Set the strength of smooth dithered input. (1...100)
155
156##### maxMemory
157
158Type: `number`
159
160Set the maximum memory to use in kilobytes.
161
162##### sample
163
164Type: `string[]`
165
166Set component sampling factors. Each item should be in the format `HxV`, for example `2x1`.
167
168#### buffer
169
170Type: `buffer`
171
172Buffer to optimize.
173
174
175## License
176
177MIT © [Imagemin](https://github.com/imagemin)