Minify GIF, JPEG and PNG images seamlessly with Node.js.
Install with npm: npm install image-min
The callback returns size
which tells you how much optimization was done.
var imagemin = require('image-min');
imagemin(img.gif, img-minified.gif, function (data) {
console.log('Saved ' + data.size);
});
imagemin(img.jpg, img-minified.jpg, { progressive: true }, function (data) {
console.log('Saved ' + data.size);
});
imagemin(img.png, img-minified.png, { pngquant: true, optimizationLevel: 4 }, function (data) {
console.log('Saved ' + data.size);
});
Optimize a GIF
, JPEG
, or PNG
image by providing a src
and dest
. Use the
options below (optionally) to configure how your images are optimized.
cache
— Whether to cache optimized imagesinterlaced
(GIF only) — Interlace gif for progressive renderingoptimizationLevel
(PNG only) — Select optimization level between 0 and 7progressive
(JPEG only) — Lossless conversion to progressive