image-2-min
v6.0.2
Published
Image minifier for NodeJS with subdirectoy support
Downloads
493
Maintainers
Readme
image-2-min
Image minifier that respects folder structure.. :)
Install
$ npm install --save image-2-min
Usage
const imagemin = require('image-2-min');
const imageminJpegtran = require('imagemin-jpegtran');
const imageminPngquant = require('imagemin-pngquant');
imagemin(['images/*.{jpg,png}'], 'build/images', {
plugins: [
imageminJpegtran()(),
imageminPngquant({quality: '65-80'})
]
}).then(files => {
console.log(files);
//=> [{data: <Buffer 89 50 4e …>, path: 'build/images/foo.jpg'}, …]
});
API
imagemin(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.
options
plugins
Type: array
Array of plugins to use.
cwd
Type: string
The working directoy for image lookups.
imagemin.buffer(buffer, [options])
Returns a promise for a buffer.
buffer
Type: buffer
The buffer to optimize.
cwd
Type: string
The working directoy for image lookups.
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