Home

Awesome

imagemin-mozjpeg

Imagemin plugin for mozjpeg

Install

$ npm install imagemin-mozjpeg

Usage

import imagemin from 'imagemin';
import imageminMozjpeg from 'imagemin-mozjpeg';

(async () => {
	await imagemin(['images/*.jpg'], {
		destination: 'build/images',
		plugins: [
			imageminMozjpeg()
		]
	});

	console.log('Images optimized');
})();

API

imageminMozjpeg(options?)(buffer)

Returns a Promise<Buffer>.

options

Type: object

quality

Type: number

Compression quality, in range 0 (worst) to 100 (perfect).

progressive

Type: boolean
Default: true

false creates baseline JPEG file.

targa

Type: boolean
Default: false

Input file is Targa format (usually not needed).

revert

Type: boolean
Default: false

Revert to standard defaults instead of mozjpeg defaults.

fastCrush

Type: boolean
Default: false

Disable progressive scan optimization.

dcScanOpt

Type: number
Default: 1

Set DC scan optimization mode.

trellis

Type: boolean
Default: true

Trellis optimization.

trellisDC

Type: boolean
Default: true

Trellis optimization of DC coefficients.

tune

Type: string
Default: hvs-psnr

Set Trellis optimization method. Available methods: psnr, hvs-psnr, ssim, ms-ssim

overshoot

Type: boolean
Default: true

Black-on-white deringing via overshoot.

arithmetic

Type: boolean
Default: false

Use arithmetic coding.

dct

Type: string
Default: int

Set DCT method:

quantBaseline

Type: boolean
Default: false

Use 8-bit quantization table entries for baseline JPEG compatibility.

quantTable

Type: number

Use predefined quantization table.

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.