Socket
Socket
Sign inDemoInstall

imagemin-optipng

Package Overview
Dependencies
197
Maintainers
7
Versions
19
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 6.0.0 to 7.0.0

42

index.js

@@ -6,19 +6,20 @@ 'use strict';

module.exports = opts => buf => {
opts = Object.assign({
module.exports = options => async buffer => {
options = {
optimizationLevel: 3,
bitDepthReduction: true,
colorTypeReduction: true,
paletteReduction: true
}, opts);
paletteReduction: true,
...options
};
if (!Buffer.isBuffer(buf)) {
return Promise.reject(new TypeError('Expected a buffer'));
if (!Buffer.isBuffer(buffer)) {
throw new TypeError('Expected a buffer');
}
if (!isPng(buf)) {
return Promise.resolve(buf);
if (!isPng(buffer)) {
return buffer;
}
const args = [
const arguments_ = [
'-strip',

@@ -29,3 +30,3 @@ 'all',

'-o',
opts.optimizationLevel,
options.optimizationLevel,
'-out',

@@ -35,24 +36,21 @@ execBuffer.output

if (!opts.bitDepthReduction) {
args.push('-nb');
if (!options.bitDepthReduction) {
arguments_.push('-nb');
}
if (!opts.colorTypeReduction) {
args.push('-nc');
if (!options.colorTypeReduction) {
arguments_.push('-nc');
}
if (!opts.paletteReduction) {
args.push('-np');
if (!options.paletteReduction) {
arguments_.push('-np');
}
args.push(execBuffer.input);
arguments_.push(execBuffer.input);
return execBuffer({
input: buf,
input: buffer,
bin: optipng,
args
}).catch(error => {
error.message = error.stderr || error.message;
throw error;
args: arguments_
});
};
{
"name": "imagemin-optipng",
"version": "6.0.0",
"description": "OptiPNG imagemin plugin",
"license": "MIT",
"repository": "imagemin/imagemin-optipng",
"author": {
"name": "Kevin Mårtensson",
"email": "kevinmartensson@gmail.com",
"url": "github.com/kevva"
},
"maintainers": [
{
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "sindresorhus.com"
},
{
"name": "Shinnosuke Watanabe",
"url": "github.com/shinnn"
}
],
"engines": {
"node": ">=6"
},
"scripts": {
"test": "xo && ava"
},
"files": [
"index.js"
],
"keywords": [
"compress",
"image",
"imageminplugin",
"img",
"minify",
"optimize",
"optipng",
"png"
],
"dependencies": {
"exec-buffer": "^3.0.0",
"is-png": "^1.0.0",
"optipng-bin": "^5.0.0"
},
"devDependencies": {
"ava": "*",
"xo": "*"
}
"name": "imagemin-optipng",
"version": "7.0.0",
"description": "Imagemin plugin for OptiPNG",
"license": "MIT",
"repository": "imagemin/imagemin-optipng",
"engines": {
"node": ">=8"
},
"scripts": {
"test": "xo && ava"
},
"files": [
"index.js"
],
"keywords": [
"imageminplugin",
"compress",
"image",
"minify",
"optimize",
"optipng",
"png"
],
"dependencies": {
"exec-buffer": "^3.0.0",
"is-png": "^2.0.0",
"optipng-bin": "^6.0.0"
},
"devDependencies": {
"ava": "^1.4.1",
"xo": "^0.24.0"
}
}

@@ -1,4 +0,4 @@

# imagemin-optipng [![Build Status](http://img.shields.io/travis/imagemin/imagemin-optipng.svg?style=flat)](https://travis-ci.org/imagemin/imagemin-optipng) [![Build status](https://ci.appveyor.com/api/projects/status/4e5msglic4m7yxst?svg=true)](https://ci.appveyor.com/project/ShinnosukeWatanabe/imagemin-optipng)
# imagemin-optipng [![Build Status](http://img.shields.io/travis/imagemin/imagemin-optipng.svg?style=flat)](https://travis-ci.org/imagemin/imagemin-optipng)
> optipng image-min plugin
> Imagemin plugin for OptiPNG

@@ -9,3 +9,3 @@

```
$ npm install --save imagemin-optipng
$ npm install imagemin-optipng
```

@@ -20,5 +20,11 @@

imagemin(['images/*.png'], 'build/images', {use: [imageminOptipng()]}).then(() => {
console.log('Images optimized');
});
(async () => {
await imagemin(['images/*.png'], 'build/images', {
use: [
imageminOptipng()
]
});
console.log('Images optimized!');
})();
```

@@ -31,6 +37,8 @@

Returns a `Promise` for a `Buffer`.
Returns a `Promise<Buffer>`.
#### options
Type: `object`
##### optimizationLevel

@@ -81,6 +89,1 @@

Buffer to optimize.
## License
MIT © [imagemin](https://github.com/imagemin)

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc