Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@mole-inc/imagemin-pngquant

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@mole-inc/imagemin-pngquant

Imagemin plugin for `pngquant`

  • 12.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3
increased by200%
Maintainers
1
Weekly downloads
 
Created
Source

imagemin-pngquant Node CI

Imagemin plugin for pngquant

Downloads Version codecov

Install

$ npm install @mole-inc/imagemin-pngquant

Usage

const imagemin = require('imagemin');
const imageminPngquant = require('@mole-inc/imagemin-pngquant');

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

	console.log('Images optimized');
})();
const fs = require('fs');
const {pngquantStream} = require('@mole-inc/imagemin-pngquant');

const src = fs.createReadStream('foo.png');
const dest = fs.createWriteStream('bar.png');
pngquantStream({quality: [0.3, 0.5]})(src).pipe(dest);

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.

pngquantStream(options?)(input)

Returns Readable.

License

This is a fork of imagemin/imagemin-pngquant.

see license file.

Keywords

FAQs

Package last updated on 04 Dec 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc