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

    Install

    npm i teenypng

    DownloadsWeekly Downloads

    0

    Version

    0.2.0

    License

    MIT

    Last publish

    Collaborators

    • mikehall314