11.0.0 • Published 24 days ago

@localnerve/imagemin-pngquant v11.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
24 days ago

imagemin-pngquant

test

Imagemin plugin for pngquant

A maintained, updated fork of imagemin-pngquant
Node 16+
ESM
Security and dependency updates

Install

$ npm install imagemin-pngquant

Prerequisites

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

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

Macosx machines must have the following package prior to install: libimagequant

brew install libimagequant

Usage

const imagemin = require('imagemin');
const imageminPngquant = require('imagemin-pngquant');

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

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

API

imageminPngquant(options?)(input)

Returns Promise<Buffer>.

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.

verbose

Type: boolean Default: false

Print verbose status messages.

input

Type: Buffer | Stream

Buffer or stream to optimize.

11.0.0

24 days ago

10.0.6

2 months ago

10.0.5

3 months ago

10.0.4

4 months ago

10.0.3

6 months ago

10.0.2

6 months ago

10.0.1

7 months ago