1. imagemin-pngquant
Imagemin plugin for `pngquant`
imagemin-pngquant
Package: imagemin-pngquant
Created by: imagemin
Last modified: Sun, 19 Jun 2022 00:37:40 GMT
Version: 9.0.2
License: MIT
Downloads: 1,918,455
Repository: https://github.com/imagemin/imagemin-pngquant

Install

npm install imagemin-pngquant
yarn add imagemin-pngquant

imagemin-pngquant GitHub Actions Status

Imagemin plugin for pngquant

Install

$ npm install imagemin-pngquant

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.

RELATED POST

Enhancing Vue.js Development: Harnessing the Potential of Vue-Loader

Enhancing Vue.js Development: Harnessing the Potential of Vue-Loader

Simplify Data Validation in Vue.js: A Step-by-Step Guide to Using Regex

Simplify Data Validation in Vue.js: A Step-by-Step Guide to Using Regex

Troubleshooting Made Easy: Common Issues and Solutions with vue-loader Without vue-cli

Troubleshooting Made Easy: Common Issues and Solutions with vue-loader Without vue-cli

Optimizing Webpack 4 with Vue CLI 3: Disabling the Cache-Loader

Optimizing Webpack 4 with Vue CLI 3: Disabling the Cache-Loader

Step-by-Step Guide: How to Add a Function to Your Vuex Plugin

Step-by-Step Guide: How to Add a Function to Your Vuex Plugin