# imagemin-pngquant

> Imagemin plugin for `pngquant`

Latest version **10.0.0** (published 2024-05-07) · MIT license · 0 weekly downloads

## Install

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

## Health

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

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

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 10.0.0 |
| Published | 2024-05-07 |
| First published | 2014-04-23 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM |
| Node | >=18 |
| Dependencies | 6 |
| Unpacked size | 7.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 326 |
| Maintainers | nothingismagick, sindresorhus, kevva, 1000ch, xhmikosr, shinnn |
| Keywords | compress, image, imageminplugin, minify, optimize, png, pngquant |

## Links

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

## Dependencies (6)

- [ow](https://npm.io/package/ow.md) ^2.0.0
- [execa](https://npm.io/package/execa.md) ^8.0.1
- [is-png](https://npm.io/package/is-png.md) ^3.0.1
- [environment](https://npm.io/package/environment.md) ^1.0.0
- [pngquant-bin](https://npm.io/package/pngquant-bin.md) ^9.0.0
- [uint8array-extras](https://npm.io/package/uint8array-extras.md) ^1.1.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) — 2024-05-07
- 9.0.2 — 2021-03-05
- 9.0.1 — 2020-09-09
- 9.0.0 — 2020-06-01
- 8.0.0 — 2019-05-30
- 7.0.0 — 2019-01-11
- 6.0.1 — 2018-12-25
- 6.0.0 — 2018-07-19
- 5.1.0 — 2018-03-15
- 5.0.1 — 2017-05-29
- 5.0.0 — 2016-04-29
- 4.2.2 — 2016-02-19
- 4.2.1 — 2016-02-18
- 4.2.0 — 2015-08-31
- 4.1.2 — 2015-07-13
- … 14 more at https://npm.io/package/imagemin-pngquant/versions

## README

# imagemin-pngquant

> [Imagemin](https://github.com/imagemin/imagemin) plugin for [`pngquant`](https://github.com/kornelski/pngquant)

## Install

```sh
npm install imagemin-pngquant
```

### Prerequisites

> **Linux** machines must have the following packages prior to install: `libpng-dev libimagequant-dev`  

```sh
sudo apt-get -y install libpng-dev libimagequant-dev
```

## Usage

```js
import imagemin from 'imagemin';
import imageminPngquant from 'imagemin-pngquant';

await imagemin(['images/*.png'], {
	destination: 'build/images',
	plugins: [
		imageminPngquant()
	]
});

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

## API

### imageminPngquant(options?)(input)

Returns `Promise<Uint8Array>`.

#### options

Type: `object`

##### speed

Type: `number`\
Default: `4`\
Values: `1` (brute-force) to `11` (fastest)

Speed `10` has 5% lower quality, but is about 8 times faster than the default. Speed `11` disables dithering and lowers compression level.

##### strip

Type: `boolean`\
Default: `false`

Remove optional metadata.

##### quality

Type: `Array<min: number, max: number>`\
Values: `Array<0...1, 0...1>`\
Example: `[0.3, 0.5]`

Instructs pngquant to use the least amount of colors required to meet or exceed
the max quality. If conversion results in quality below the min quality the
image won't be saved.

Min and max are numbers in range 0 (worst) to 1 (perfect), similar to JPEG.

##### dithering

Type: `number | boolean`\
Default: `1` (full)\
Values: `0...1`

Set the dithering level using a fractional number between 0 (none) and 1 (full).

Pass in `false` to disable dithering.

##### posterize

Type: `number`

Truncate number of least significant bits of color (per channel). Use this when image will be output on low-depth displays (e.g. 16-bit RGB). pngquant will make almost-opaque pixels fully opaque and will reduce amount of semi-transparent colors.

#### input

Type: `Uint8Array`

Image data to optimize.

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