# imagemin-mozjpeg

> Imagemin plugin for mozjpeg

Latest version **10.0.0** (published 2021-12-17) · MIT license · 0 weekly downloads

## Install

```sh
npm install imagemin-mozjpeg
pnpm add imagemin-mozjpeg
yarn add imagemin-mozjpeg
bun add imagemin-mozjpeg
```

## Health

**Score 28/100 (F)** — status: abandoned.

Positive: has types package; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 10.0.0 |
| Published | 2021-12-17 |
| First published | 2014-04-23 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | separate (@types/imagemin-mozjpeg) |
| Module format | ESM |
| Node | ^12.20.0 \|\| ^14.13.1 \|\| >=16.0.0 |
| Dependencies | 3 |
| Unpacked size | 7.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 256 |
| Author | Kevin Mårtensson |
| Maintainers | nothingismagick, sindresorhus, kevva, shinnn, 1000ch, bradbaris, xhmikosr |
| Keywords | compress, image, imageminplugin, img, jpeg, jpg, minify, mozjpeg, optimize |

## Links

- npm: https://www.npmjs.com/package/imagemin-mozjpeg
- Repository: https://github.com/imagemin/imagemin-mozjpeg
- Homepage: https://github.com/imagemin/imagemin-mozjpeg#readme
- Issues: https://github.com/imagemin/imagemin-mozjpeg/issues
- npm.io page: https://npm.io/package/imagemin-mozjpeg

## Dependencies (3)

- [execa](https://npm.io/package/execa.md) ^6.0.0
- [is-jpg](https://npm.io/package/is-jpg.md) ^3.0.0
- [mozjpeg](https://npm.io/package/mozjpeg.md) ^8.0.0

## Alternatives

- [exif-parser](https://npm.io/package/exif-parser.md) — 3.8M weekly downloads
- [vite-plugin-compression](https://npm.io/package/vite-plugin-compression.md) — 569.5K weekly downloads
- [pica](https://npm.io/package/pica.md) — 442.4K weekly downloads
- [@reportportal/client-javascript](https://npm.io/package/@reportportal/client-javascript.md) — 408.8K weekly downloads
- [@tldraw/state](https://npm.io/package/@tldraw/state.md) — 316.0K weekly downloads

## Recent versions

- 10.0.0 (latest) — 2021-12-17
- 9.0.0 — 2020-05-29
- 8.0.0 — 2018-10-30
- 7.0.0 — 2017-12-27
- 6.0.0 — 2016-04-29
- 5.1.0 — 2015-04-22
- 5.0.0 — 2015-04-20
- 4.0.0 — 2014-10-24
- 3.1.0 — 2014-10-21
- 3.0.0 — 2014-10-20
- 2.0.0 — 2014-09-10
- 1.0.0 — 2014-08-18
- 0.1.2 — 2014-04-25
- 0.1.1 — 2014-04-23
- 0.1.0 — 2014-04-23

## README

# imagemin-mozjpeg

> [Imagemin](https://github.com/imagemin/imagemin) plugin for [mozjpeg](https://github.com/mozilla/mozjpeg)

## Install

```
$ npm install imagemin-mozjpeg
```

## Usage

```js
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.

- `0` One scan for all components
- `1` One scan per component
- `2` Optimize between one scan for all components and one scan for 1st component plus one scan for remaining components

##### trellis

Type: `boolean`\
Default: `true`

[Trellis optimization](https://en.wikipedia.org/wiki/Trellis_quantization).

##### 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](https://en.wikipedia.org/wiki/Arithmetic_coding).

##### dct

Type: `string`\
Default: `int`

Set [DCT](https://en.wikipedia.org/wiki/Discrete_cosine_transform) method:

- `int` Use integer DCT
- `fast` Use fast integer DCT (less accurate)
- `float` Use floating-point DCT

##### quantBaseline

Type: `boolean`\
Default: `false`

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

##### quantTable

Type: `number`

Use predefined quantization table.

- `0` JPEG Annex K
- `1` Flat
- `2` Custom, tuned for MS-SSIM
- `3` ImageMagick table by N. Robidoux
- `4` Custom, tuned for PSNR-HVS
- `5` 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.

---
_Source: https://npm.io/package/imagemin-mozjpeg · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
