Imagemin plugin for mozjpeg
npm install imagemin-mozjpeg```
$ npm install imagemin-mozjpeg
`js
import imagemin from 'imagemin';
import imageminMozjpeg from 'imagemin-mozjpeg';
(async () => {
await imagemin(['images/*.jpg'], {
destination: 'build/images',
plugins: [
imageminMozjpeg()
]
});
console.log('Images optimized');
})();
`
Returns a Promise.
#### options
Type: object
##### quality
Type: number
Compression quality, in range 0 (worst) to 100 (perfect).
##### progressive
Type: boolean\true
Default:
false creates baseline JPEG file.
##### targa
Type: boolean\false
Default:
Input file is Targa format (usually not needed).
##### revert
Type: boolean\false
Default:
Revert to standard defaults instead of mozjpeg defaults.
##### fastCrush
Type: boolean\false
Default:
Disable progressive scan optimization.
##### dcScanOpt
Type: number\1
Default:
Set DC scan optimization mode.
- 0 One scan for all components1
- One scan per component2
- Optimize between one scan for all components and one scan for 1st component plus one scan for remaining components
##### trellis
Type: boolean\true
Default:
##### trellisDC
Type: boolean\true
Default:
Trellis optimization of DC coefficients.
##### tune
Type: string\hvs-psnr
Default:
Set Trellis optimization method. Available methods: psnr, hvs-psnr, ssim, ms-ssim
##### overshoot
Type: boolean\true
Default:
Black-on-white deringing via overshoot.
##### arithmetic
Type: boolean\false
Default:
Use arithmetic coding.
##### dct
Type: string\int
Default:
Set DCT method:
- int Use integer DCTfast
- Use fast integer DCT (less accurate)float
- Use floating-point DCT
##### quantBaseline
Type: boolean\false
Default:
Use 8-bit quantization table entries for baseline JPEG compatibility.
##### quantTable
Type: number
Use predefined quantization table.
- 0 JPEG Annex K1
- Flat2
- Custom, tuned for MS-SSIM3
- ImageMagick table by N. Robidoux4
- Custom, tuned for PSNR-HVS5
- Table from paper by Klein, Silverstein and Carney
##### smooth
Type: number
Set the strength of smooth dithered input. (1...100)
##### maxMemory
Type: number
Set the maximum memory to use in kilobytes.
##### sample
Type: string[]
Set component sampling factors. Each item should be in the format HxV, for example 2x1.
#### buffer
Type: buffer`
Buffer to optimize.