New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

imgo

Package Overview
Dependencies
Maintainers
1
Versions
34
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

imgo

Optimize image buffer

latest
Source
npmnpm
Version
4.0.0
Version published
Maintainers
1
Created
Source

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

Keywords

optimize

FAQs

Package last updated on 05 Dec 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts