imagemin
Minify images seamlessly
Install
$ npm install --save imagemin
Usage
const Imagemin = ; ;
You can use gulp-rename to rename your files:
const Imagemin = ;const rename = ; ;
API
new Imagemin()
Creates a new Imagemin
instance.
.src(file)
Type: array
, buffer
or string
Set the files to be optimized. Takes a buffer, glob string or an array of glob strings as argument.
.dest(folder)
Type: string
Set the destination folder to where your files will be written. If you don't set any destination no files will be written.
.use(plugin)
Type: function
Add a plugin
to the middleware stack.
.run(callback)
Type: function
Optimize your files with the given settings.
callback(err, files)
The callback will return an array of vinyl files in files
.
Plugins
The following plugins are bundled with imagemin:
- gifsicle — Compress GIF images.
- jpegtran — Compress JPG images.
- optipng — Compress PNG images losslessly.
- svgo — Compress SVG images.
.gifsicle(options)
Compress GIF images.
const Imagemin = ; ;
.jpegtran(options)
Compress JPG images.
const Imagemin = ; ;
.optipng(options)
Lossless compression of PNG images.
const Imagemin = ; ;
.svgo(options)
Compress SVG images.
const Imagemin = ; ;
Related
- imagemin-cli - CLI for this module
- imagemin-app - GUI app for this module.
- gulp-imagemin - Gulp plugin.
- grunt-contrib-imagemin - Grunt plugin.
License
MIT © imagemin