Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

imagemin-advpng

Package Overview
Dependencies
Maintainers
2
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

imagemin-advpng - npm Package Compare versions

Comparing version 2.0.0 to 2.1.0

93

index.js

@@ -11,3 +11,51 @@ 'use strict';

*
* @param {Object} file
* @param {String} enc
* @param {Object} opts
* @param {Function} cb
* @api private
*/
function plugin(file, enc, opts, cb) {
if (file.isNull()) {
cb(null, file);
return;
}
if (file.isStream()) {
cb(new Error('Streaming is not supported'));
return;
}
if (!isPng(file.contents)) {
cb(null, file);
return;
}
var exec = new ExecBuffer();
var args = ['--recompress', '-q'];
var optimizationLevel = opts.optimizationLevel || 3;
if (typeof optimizationLevel === 'number') {
args.push('-' + optimizationLevel);
}
exec
.dest(exec.src())
.use(advpng, args.concat([exec.src()]))
.run(file.contents, function (err, buf) {
if (err) {
cb(err);
return;
}
file.contents = buf;
cb(null, file);
});
}
/**
* Module exports
*
* @param {Object} opts
* @api public

@@ -20,38 +68,19 @@ */

return through.obj(function (file, enc, cb) {
if (file.isNull()) {
cb(null, file);
return;
}
plugin(file, enc, opts, cb);
});
};
if (file.isStream()) {
cb(new Error('Streaming is not supported'));
return;
}
/**
* Module exports constructor
*
* @param {Object} opts
* @api public
*/
if (!isPng(file.contents)) {
cb(null, file);
return;
}
module.exports.ctor = function (opts) {
opts = opts || {};
var exec = new ExecBuffer();
var args = ['--recompress', '-q'];
var optimizationLevel = opts.optimizationLevel || 3;
if (typeof optimizationLevel === 'number') {
args.push('-' + optimizationLevel);
}
exec
.dest(exec.src())
.use(advpng, args.concat([exec.src()]))
.run(file.contents, function (err, buf) {
if (err) {
cb(err);
return;
}
file.contents = buf;
cb(null, file);
});
return through.ctor({ objectMode: true }, function (file, enc, cb) {
plugin(file, enc, opts, cb);
});
};
{
"name": "imagemin-advpng",
"version": "2.0.0",
"version": "2.1.0",
"description": "advpng imagemin plugin",

@@ -5,0 +5,0 @@ "license": "MIT",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc