first commit
This commit is contained in:
52
build/node_modules/imagemin-optipng/index.js
generated
vendored
Normal file
52
build/node_modules/imagemin-optipng/index.js
generated
vendored
Normal file
@@ -0,0 +1,52 @@
|
||||
'use strict';
|
||||
const execBuffer = require('exec-buffer');
|
||||
const isPng = require('is-png');
|
||||
const optipng = require('optipng-bin');
|
||||
|
||||
module.exports = opts => buf => {
|
||||
opts = Object.assign({
|
||||
optimizationLevel: 3,
|
||||
bitDepthReduction: true,
|
||||
colorTypeReduction: true,
|
||||
paletteReduction: true
|
||||
}, opts);
|
||||
|
||||
if (!Buffer.isBuffer(buf)) {
|
||||
return Promise.reject(new TypeError('Expected a buffer'));
|
||||
}
|
||||
|
||||
if (!isPng(buf)) {
|
||||
return Promise.resolve(buf);
|
||||
}
|
||||
|
||||
const args = [
|
||||
'-strip', 'all',
|
||||
'-clobber',
|
||||
'-fix',
|
||||
'-o', opts.optimizationLevel,
|
||||
'-out', execBuffer.output
|
||||
];
|
||||
|
||||
if (!opts.bitDepthReduction) {
|
||||
args.push('-nb');
|
||||
}
|
||||
|
||||
if (!opts.colorTypeReduction) {
|
||||
args.push('-nc');
|
||||
}
|
||||
|
||||
if (!opts.paletteReduction) {
|
||||
args.push('-np');
|
||||
}
|
||||
|
||||
args.push(execBuffer.input);
|
||||
|
||||
return execBuffer({
|
||||
input: buf,
|
||||
bin: optipng,
|
||||
args
|
||||
}).catch(err => {
|
||||
err.message = err.stderr || err.message;
|
||||
throw err;
|
||||
});
|
||||
};
|
||||
21
build/node_modules/imagemin-optipng/license
generated
vendored
Normal file
21
build/node_modules/imagemin-optipng/license
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) imagemin
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
88
build/node_modules/imagemin-optipng/package.json
generated
vendored
Normal file
88
build/node_modules/imagemin-optipng/package.json
generated
vendored
Normal file
@@ -0,0 +1,88 @@
|
||||
{
|
||||
"_from": "imagemin-optipng",
|
||||
"_id": "imagemin-optipng@5.2.1",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha1-0i2kEsCfX/AKQzmWC5ioix2+hpU=",
|
||||
"_location": "/imagemin-optipng",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "tag",
|
||||
"registry": true,
|
||||
"raw": "imagemin-optipng",
|
||||
"name": "imagemin-optipng",
|
||||
"escapedName": "imagemin-optipng",
|
||||
"rawSpec": "",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "latest"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"#USER",
|
||||
"/"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/imagemin-optipng/-/imagemin-optipng-5.2.1.tgz",
|
||||
"_shasum": "d22da412c09f5ff00a4339960b98a88b1dbe8695",
|
||||
"_spec": "imagemin-optipng",
|
||||
"_where": "/Users/asciidisco/Desktop/asciidisco.com/build",
|
||||
"author": {
|
||||
"name": "Kevin Mårtensson",
|
||||
"email": "kevinmartensson@gmail.com",
|
||||
"url": "github.com/kevva"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/imagemin/imagemin-optipng/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"dependencies": {
|
||||
"exec-buffer": "^3.0.0",
|
||||
"is-png": "^1.0.0",
|
||||
"optipng-bin": "^3.0.0"
|
||||
},
|
||||
"deprecated": false,
|
||||
"description": "OptiPNG imagemin plugin",
|
||||
"devDependencies": {
|
||||
"ava": "*",
|
||||
"pify": "^2.3.0",
|
||||
"xo": "*"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=4"
|
||||
},
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"homepage": "https://github.com/imagemin/imagemin-optipng#readme",
|
||||
"keywords": [
|
||||
"compress",
|
||||
"image",
|
||||
"imageminplugin",
|
||||
"img",
|
||||
"minify",
|
||||
"optimize",
|
||||
"optipng",
|
||||
"png"
|
||||
],
|
||||
"license": "MIT",
|
||||
"maintainers": [
|
||||
{
|
||||
"name": "Sindre Sorhus",
|
||||
"email": "sindresorhus@gmail.com",
|
||||
"url": "sindresorhus.com"
|
||||
},
|
||||
{
|
||||
"name": "Shinnosuke Watanabe",
|
||||
"url": "github.com/shinnn"
|
||||
}
|
||||
],
|
||||
"name": "imagemin-optipng",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/imagemin/imagemin-optipng.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "xo && ava"
|
||||
},
|
||||
"version": "5.2.1",
|
||||
"xo": {
|
||||
"esnext": true
|
||||
}
|
||||
}
|
||||
82
build/node_modules/imagemin-optipng/readme.md
generated
vendored
Normal file
82
build/node_modules/imagemin-optipng/readme.md
generated
vendored
Normal file
@@ -0,0 +1,82 @@
|
||||
# imagemin-optipng [](https://travis-ci.org/imagemin/imagemin-optipng) [](https://ci.appveyor.com/project/ShinnosukeWatanabe/imagemin-optipng)
|
||||
|
||||
> optipng image-min plugin
|
||||
|
||||
|
||||
## Install
|
||||
|
||||
```
|
||||
$ npm install --save imagemin-optipng
|
||||
```
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
const imagemin = require('imagemin');
|
||||
const imageminOptipng = require('imagemin-optipng');
|
||||
|
||||
imagemin(['images/*.png'], 'build/images', {use: [imageminOptipng()]}).then(() => {
|
||||
console.log('Images optimized');
|
||||
});
|
||||
```
|
||||
|
||||
|
||||
## API
|
||||
|
||||
### imageminOptipng([options])(buffer)
|
||||
|
||||
Returns a `Promise` for a `Buffer`.
|
||||
|
||||
#### options
|
||||
|
||||
##### optimizationLevel
|
||||
|
||||
Type: `number`<br>
|
||||
Default: `3`
|
||||
|
||||
Select an optimization level between `0` and `7`.
|
||||
|
||||
> The optimization level 0 enables a set of optimization operations that require minimal effort. There will be no changes to image attributes like bit depth or color type, and no recompression of existing IDAT datastreams. The optimization level 1 enables a single IDAT compression trial. The trial chosen is what. OptiPNG thinks it’s probably the most effective. The optimization levels 2 and higher enable multiple IDAT compression trials; the higher the level, the more trials.
|
||||
|
||||
Level and trials:
|
||||
|
||||
1. 1 trial
|
||||
2. 8 trials
|
||||
3. 16 trials
|
||||
4. 24 trials
|
||||
5. 48 trials
|
||||
6. 120 trials
|
||||
7. 240 trials
|
||||
|
||||
##### bitDepthReduction
|
||||
|
||||
Type: `boolean`<br>
|
||||
Default: `true`
|
||||
|
||||
Apply bit depth reduction.
|
||||
|
||||
##### colorTypeReduction
|
||||
|
||||
Type: `boolean`<br>
|
||||
Default: `true`
|
||||
|
||||
Apply color type reduction.
|
||||
|
||||
##### paletteReduction
|
||||
|
||||
Type: `boolean`<br>
|
||||
Default: `true`
|
||||
|
||||
Apply palette reduction.
|
||||
|
||||
#### buffer
|
||||
|
||||
Type: `Buffer`
|
||||
|
||||
Buffer to optimize.
|
||||
|
||||
|
||||
## License
|
||||
|
||||
MIT © [imagemin](https://github.com/imagemin)
|
||||
Reference in New Issue
Block a user