How to use the pngquant-bin.path function in pngquant-bin

To help you get started, we’ve selected a few pngquant-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 imagemin / imagemin / lib / plugins / pngquant.js View on Github external
'use strict';

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

/**
 * pngquant 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);
};

pngquant-bin

`pngquant` wrapper that makes it seamlessly available as a local dependency

GPL-3.0+
Latest version published 8 months ago

Package Health Score

64 / 100
Full package analysis

Popular pngquant-bin functions