How to use optipng-bin - 4 common examples

To help you get started, we’ve selected a few optipng-bin examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github iolo / pictor / libs / imgutils.js View on Github external
.then(function (format) {
      switch (format) {
        case 'JPEG':
          var jpegtran = require('jpegtran-bin').path;
          return Q.nfcall(execFile, jpegtran, ['-copy', 'none', '-optimize', '-outfile', dst, src]);
        case 'PNG':
          var optipng = require('optipng-bin').path;
          return Q.nfcall(execFile, optipng, ['-quiet', '-force', '-strip', 'all', '-out', dst, src]);
        case 'GIF':
          var gifsicle = require('gifsicle').path;
          return Q.nfcall(execFile, gifsicle, ['--careful', '-w', '-o', dst, src]);
      }
      // unsupported format!?
      // simply convert it without profile data!
      return convert(src, dst);
    });
}
github gluckgames / pixi-packer / lib / image_processor.js View on Github external
.then(function() {
            if (compression === "none") {
                return Q.resolve();
            } else if (compression === "optipng") {
                return Q.nfcall(execFile, require("optipng-bin").path, [cachedImagePath]);
            } else if (compression === "pngquant") {
                return Q.nfcall(execFile, require("pngquant-bin"), ["-o", cachedImagePath, cachedImagePath, "-f"]);
            } else {
                throw new Error("Compression '" + compression + "' is not supported");
            }
        });
    };
github imagemin / imagemin / lib / plugins / optipng.js View on Github external
'use strict';

var execFile = require('child_process').execFile;
var fs = require('fs');
var imageType = require('image-type');
var optipng = require('optipng-bin').path;
var tempfile = require('tempfile');
var rm = require('rimraf');

/**
 * optipng image-min plugin
 *
 * @param {Object} opts
 * @api public
 */

module.exports = function (opts) {
    opts = opts || {};

    return function (file, imagemin, cb) {
        if (imageType(file.contents) !== 'png') {
            return cb();
github imagemin / imagemin / index.js View on Github external
Imagemin.prototype._optimizePng = function () {
    var args = ['-strip', 'all', '-quiet'];
    var optipng = require('optipng-bin').stream;
    var pngquant;

    if (typeof this.optimizationLevel === 'number') {
        args.push('-o', this.optimizationLevel);
    }

    if (this.opts.pngquant) {
        pngquant = require('pngquant-bin').path;
        return spawn(optipng, args).stdout.pipe(spawn(pngquant, ['-']));
    }

    return spawn(optipng, args);
};

optipng-bin

OptiPNG wrapper that makes it seamlessly available as a local dependency

MIT
Latest version published 3 years ago

Package Health Score

65 / 100
Full package analysis

Popular optipng-bin functions