gulp-imagemin
    Overview
    Documentation
    Insights
    Code
    Contributors
    Dependencies
    Alternatives

gulp-imagemin

Minify PNG, JPEG, GIF and SVG images

6.1.0  •  Published 3 months ago  •  by Sindre Sorhus  •  MIT License

Minify PNG, JPEG, GIF and SVG images with imagemin

Issues with the output should be reported on the imagemin issue tracker.

Install

$ npm install --save-dev gulp-imagemin

Usage

Basic

const gulp = require('gulp');
const imagemin = require('gulp-imagemin');

exports.default = () => (
	gulp.src('src/images/*')
		.pipe(imagemin())
		.pipe(gulp.dest('dist/images'))
);

Custom plugin options

// …
.pipe(imagemin([
	imagemin.gifsicle({interlaced: true}),
	imagemin.jpegtran({progressive: true}),
	imagemin.optipng({optimizationLevel: 5}),
	imagemin.svgo({
		plugins: [
			{removeViewBox: true},
			{cleanupIDs: false}
		]
	})
]))
// …

Note that you may come across an older, implicit syntax. In versions < 3, the same was written like this:

// …
.pipe(imagemin({
	interlaced: true,
	progressive: true,
	optimizationLevel: 5,
	svgoPlugins: [
		{
			removeViewBox: true
		}
	]
}))
// …

Custom plugin options and custom gulp-imagemin options

// …
.pipe(imagemin([
	imagemin.svgo({
		plugins: [
			{
				removeViewBox: true
			}
		]
	})
], {
	verbose: true
}))
// …

API

Comes bundled with the following lossless optimizers:

These are bundled for convenience and most users will not need anything else.

imagemin(plugins?, options?)

Unsupported files are ignored.

plugins

Type: Array
Default: [imagemin.gifsicle(), imagemin.jpegtran(), imagemin.optipng(), imagemin.svgo()]

Plugins to use. This will overwrite the default plugins. Note that the default plugins comes with good defaults and should be sufficient in most cases. See the individual plugins for supported options.

options

Type: object

verbose

Type: boolean
Default: false

Enabling this will log info on every image passed to gulp-imagemin:

gulp-imagemin: ✔ image1.png (already optimized)
gulp-imagemin: ✔ image2.png (saved 91 B - 0.4%)
How do you feel about the name Devstore for this site?

Popularity

Weekly Downloads
106.1K
Stars
1.7K

Maintenance

Development

Last ver 3 months ago
Created 6 years ago
Last commit 10 days ago
14 days between commits

Technology

Node version: 10.16.0
8.2K unpacked

Compliance

MIT License
OSI Approved
0 vulnerabilities

Contributors

24 contributors
Sindre Sorhus
Maintainer, 109 commits, 25 merges
Kevin Martensson
Maintainer, 23 commits, 1 merges, 5 PRs
Works at imagemin yeoman
XhmikosR
Maintainer, 3 commits, 4 PRs
Stephan Schneider
2 commits, 2 PRs
Works at contentful
Shinnosuke Watanabe
Maintainer, 1 commits, 1 PRs
Blaine Bublitz
1 commits, 1 PRs
Works at Paying the maintainers Tidelift

Tags

gulpplugin
imagemin
image
img
picture
photo
minify
minifier
compress
png
jpg
jpeg
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