imagemin-optipng
Advanced tools
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
No contributors or author data
MaintenancePackage does not specify a list of contributors or an author in package.json.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
86
0
4171
44
1
+ Addedis-png@2.0.0(transitive)
+ Addedoptipng-bin@6.0.0(transitive)
- Removedis-png@1.1.0(transitive)
- Removedoptipng-bin@5.1.0(transitive)
Updatedis-png@^2.0.0
Updatedoptipng-bin@^6.0.0