Imagemin plugin for all mozjpeg binaries (cjpeg and jpegtran).
What is difference between imagemin-mozjpeg:
- Contains binaries delivered by
mozjpeg:cjpegandjpegtran(feel free to send a PR with new binary). - No security vulnerabilities.
- Latest version.
$ npm install imagemin-mozjpegconst imagemin = require("imagemin");
const imageminCjpeg = require("imagemin-mozjpeg").cjpeg; // alias `mozjpeg`
(async () => {
await imagemin(["images/*.jpg"], "build/images", {
use: [imageminCjpeg()]
});
console.log("Images optimized");
})();const imagemin = require("imagemin");
const imageminJpegtran = require("imagemin-mozjpeg").jpegtran;
(async () => {
await imagemin(["images/*.jpg"], "build/images", {
use: [imageminJpegtran()]
});
console.log("Images optimized");
})();Returns a Promise<Buffer>.
Type: number
Compression quality, in range 0 (worst) to 100 (perfect).
Type: boolean
Default: true
false creates baseline JPEG file.
Type: boolean
Default: false
Input file is Targa format (usually not needed).
Type: boolean
Default: false
Revert to standard defaults instead of mozjpeg defaults.
Type: boolean
Default: false
Disable progressive scan optimization.
Type: number
Default: 1
Set DC scan optimization mode.
0One scan for all components1One scan per component2Optimize between one scan for all components and one scan for 1st component plus one scan for remaining components
Type: boolean
Default: true
Type: boolean
Default: true
Trellis optimization of DC coefficients.
Type: string
Default: hvs-psnr
Set Trellis optimization method. Available methods: psnr, hvs-psnr, ssim, ms-ssim
Type: boolean
Default: true
Black-on-white deringing via overshoot.
Type: boolean
Default: false
Use arithmetic coding.
Type: string
Default: int
Set DCT method:
intUse integer DCTfastUse fast integer DCT (less accurate)floatUse floating-point DCT
Type: boolean
Default: false
Use 8-bit quantization table entries for baseline JPEG compatibility.
Type: number
Use predefined quantization table.
0JPEG Annex K1Flat2Custom, tuned for MS-SSIM3ImageMagick table by N. Robidoux4Custom, tuned for PSNR-HVS5Table from paper by Klein, Silverstein and Carney
Type: number
Set the strength of smooth dithered input. (1...100)
Type: number
Set the maximum memory to use in kilobytes.
Type: string[]
Set component sampling factors. Each item should be in the format HxV, for example 2x1.
Type: buffer
Buffer to optimize.
Returns a promise for a buffer.
Type: boolean
Default: false
Use default options for jpegtran (mozjpeg change default options of jpegtran).
Example progressive option is true by default.
Optimize Huffman table is enabled by default (--optimize flag).
For more information about default options please run:
node_modules/.bin/jpegtran --helpType: boolean
Default: true (mozjpeg enable this by default, you can be disable using revert option)
Lossless conversion to progressive.
Type: boolean
Default: false
Use arithmetic coding.
Type: buffer
Buffer to optimize.