imagemin
    Overview
    Documentation
    Insights
    Code
    Contributors
    Dependencies
    Alternatives

imagemin

Minify images seamlessly

7.0.0  •  Published 5 months ago  •  by imagemin  •  MIT License

Minify images seamlessly

Install

$ npm install imagemin

Usage

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

(async () => {
	const files = await imagemin(['images/*.{jpg,png}'], {
		destination: 'build/images',
		plugins: [
			imageminJpegtran(),
			imageminPngquant({
				quality: [0.6, 0.8]
			})
		]
	});

	console.log(files);
	//=> [{data: <Buffer 89 50 4e …>, path: 'build/images/foo.jpg'}, …]
})();

API

imagemin(input, options?)

Returns Promise<object[]> in the format {data: Buffer, sourcePath: string, destinationPath: string}.

input

Type: string[]

File paths or glob patterns.

options

Type: object

destination

Type: string

Set the destination folder to where your files will be written. If no destination is specified, no files will be written.

plugins

Type: Array

Plugins to use.

glob

Type: boolean
Default: true

Enable globbing when matching file paths.

imagemin.buffer(buffer, options?)

Returns Promise<Buffer>.

buffer

Type: Buffer

Buffer to optimize.

options

Type: object

plugins

Type: Array

Plugins to use.

Related

Popularity

Weekly Downloads
719.0K
Stars
3.6K

Maintenance

Development

Last ver 5 months ago
Created 6 years ago
Last commit 3 days ago
8 days between commits

Technology

Node version: 10.16.0
5.8K unpacked

Compliance

MIT License
OSI Approved
0 vulnerabilities

Contributors

20 contributors
Kevin Martensson
Maintainer, 189 commits, 10 merges, 5 PRs
Works at imagemin yeoman
Sindre Sorhus
Maintainer, 40 commits, 9 merges, 1 PRs
shinnn
Maintainer, 23 commits, 2 merges, 2 PRs
Shogo Sensui
Maintainer, 1 commits, 1 merges, 1 PRs
Works at merpay, mercari
Steven Vachon
1 commits, 1 PRs
Works at Grafana Labs
Tyler Ball
1 commits, 1 PRs
Works at Shopify

Tags

minify
compress
image
images
jpeg
jpg
png
gif
svg
Ready for the next level?
Join Devstore's founding team to help us build the ultimate open-source app store, work with the latest technologies, and enjoy great culture, impact and autonomy
© 2019 Devstore, Inc.
Devstore helps developers find and use open-source packages, so they can focus on building amazing things