imgo
v4.0.0
Published
Optimize image buffer
Downloads
64
Maintainers
Readme
imgo
Optimize buffer of PNG, JPEG, GIF, SVG images.
Install
$ npm install imgo
Usage
JavaScript
const fs = require('fs');
const imgo = require('imgo');
fs.readFile('image.png', (error, data) => {
imgo(data, {
pngquant : true,
optipng : true,
zopflipng : true,
pngcrush : true
}).then(optimized => {
console.log('optimized image buffer', optimized);
});
});
fs.readFile('image.jpg', (error, data) => {
imgo(data, {
jpegRecompress : true,
jpegoptim : true,
mozjpeg : true,
guetzli : true
}).then(optimized => {
console.log('optimized image buffer', optimized);
});
});
fs.readFile('image.gif', (error, data) => {
imgo(data, {
gifsicle : true
}).then(optimized => {
console.log('optimized image buffer', optimized);
});
});
fs.readFile('image.svg', (error, data) => {
imgo(data, {
svgo : true
}).then(optimized => {
console.log('optimized image buffer', optimized);
});
});
CLI
# imgo help
$ imgo --help
# apply optipng and pngquant
$ cat image.png | imgo --optipng --pngquant > optimized.png
# apply all jpeg optimizers and out diff
$ cat image.jpg | imgo --jpg --info > optimized.jpg
# apply to jpeg files
$ imgo --jpg --info *.jpg
License
MIT: http://1000ch.mit-license.org