Minify images seamlessly
Introduction
Fork form imagemin.
support keep and customize folder structure
Install
$ npm install --save-dev imagemin-keep-folder
Usage
// as usualconst imagemin = ; ;
// keep folder structure as inputconst imagemin = ; ;// for example// images/a.jpg => images/a.jpg// images/foo/a.jpg => images/foo/a.jpg// images/foo/bar/a.jpg => images/foo/bar/a.jpg
// keep folder structure as input use imagemin-webpconst imagemin = ;const imageminWebp = ; ;// for example// images/a.jpg => images/a.webp// images/foo/a.jpg => images/foo/a.webp// images/foo/bar/a.jpg => images/foo/bar/a.webp
// customize folder structure as input use imagemin-webpconst imagemin = ;const imageminWebp = ; ;// for example// images/a.jpg => .webp/a.webp// images/foo/a.jpg => .webp/foo/a.webp// images/foo/bar/a.jpg => .webp/foo/bar/a.webp
API
imagemin
same asimagemin(input, output, [options])
Returns Promise<Object[]>
in the format {data: Buffer, path: String}
.
input
Type: Array
Files to be optimized. See supported minimatch
patterns.
output
Type: string
Set the destination folder to where your files will be written. If no destination is specified no files will be written. If no destination is specified, files will be written and keep folder structure
options
Type: Object
replaceOutputDir (new options)
Type: Function
Returns String
(new output dir)
plugins
Type: Array
Plugins to use.
imagemin.buffer(buffer, [options])
Returns Promise<Buffer>
.
buffer
Type: Buffer
Buffer to optimize.
options
Type: Object
plugins
Type: Array
Plugins to use.
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