teenypng

0.2.0 • Public • Published

teenypng

Optimize PNG + JPEG images with TinyPNG.

Command Line

Install with NPM.

$ npm install -g teenypng
$ teenypng images/*.png --apikey XXXXXXXXXX

As a module

Install

$ npm install --save-dev teenypng

Use

"use strict";
 
var teenypng = require("teenypng");
teenypng("image.png", { "apikey": "XXXXXXXXXX" }, function (err, optimized) {
    // optimized = {
    //     "input": {
    //          "size": 207565,
    //          "name": "image.png"
    //     },
    //     "output": {
    //         "size": 63669,
    //         "ratio": 0.307,
    //         "image": <Buffer with compressed image>
    //     }
    // }
});

Settings

  • apikey: Your API key from tinypng.com (required)
  • onlyStats: Do not download the optimized file (optional, default: false)
"use strict";
 
var teenypng, settings;
 
teenypng = require("teenypng");
settings = {
    "apikey": "XXXXXXXXXX",
    "onlyStats": true
};
 
teenypng("image.png", settings, function (err, optimized) {
    // optimized = {
    //     "input": {
    //          "size": 207565,
    //          "name": "image.png"
    //     },
    //     "output": {
    //         "size": 63669,
    //         "ratio": 0.307,
    //         "url": "https://path.to.optimized/image.png"
    //     }
    // }
});

Tests

Test with nodeunit

$ npm test

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 0.2.0
    0
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 0.2.0
    0
  • 0.1.1
    1
  • 0.1.0
    0

Package Sidebar

Install

npm i teenypng

Weekly Downloads

1

Version

0.2.0

License

MIT

Last publish

Collaborators

  • mikehall314