|
1 viikko sitten | |
---|---|---|
.. | ||
index.js | 1 viikko sitten | |
license | 1 viikko sitten | |
package.json | 1 viikko sitten | |
readme.md | 1 viikko sitten |
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}'], {
destination: 'build/images',
plugins: [
imageminJpegtran(),
imageminPngquant({
quality: [0.6, 0.8]
})
]
});
console.log(files);
//=> [{data: <Buffer 89 50 4e …>, destinationPath: 'build/images/foo.jpg'}, …]
})();
Returns Promise<object[]>
in the format {data: Buffer, sourcePath: string, destinationPath: string}
.
Type: string[]
File paths or glob patterns.
Type: object
Type: string
Set the destination folder to where your files will be written. If no destination is specified, no files will be written.
Type: Array
Plugins to use.
Type: boolean
Default: true
Enable globbing when matching file paths.
Returns Promise<Buffer>
.
Type: Buffer
Buffer to optimize.
Type: object
Type: Array
Plugins to use.
We also provide a hosted API for imagemin which may simplify your use case.
<img src="https://badges.saasify.sh?text=View%20Hosted%20API" height="40"/>