Björn f184cd7e2a | 4 years ago | |
---|---|---|
.. | ||
node_modules/make-dir | 4 years ago | |
index.js | 4 years ago | |
license | 4 years ago | |
package.json | 4 years ago | |
readme.md | 4 years ago |
Minify images seamlessly
$ npm install imagemin
const imagemin = require('imagemin');
const imageminJpegtran = require('imagemin-jpegtran');
const imageminPngquant = require('imagemin-pngquant');
(async () => {
const files = await imagemin(['images/*.{jpg,png}'], 'build/images', {
plugins: [
imageminJpegtran(),
imageminPngquant({quality: '65-80'})
]
});
console.log(files);
//=> [{data: <Buffer 89 50 4e …>, path: 'build/images/foo.jpg'}, …]
})();
Returns Promise<Object[]>
in the format {data: Buffer, path: string}
.
Type: string[]
Files to be optimized. See supported minimatch
patterns.
Type: string
Set the destination folder to where your files will be written. If no destination is specified no files will be written.
Type: Object
Type: Array
Plugins to use.
Returns Promise<Buffer>
.
Type: Buffer
Buffer to optimize.
Type: Object
Type: Array
Plugins to use.
MIT © imagemin