first commit
This commit is contained in:
84
build/node_modules/imagemin-webp/index.js
generated
vendored
Normal file
84
build/node_modules/imagemin-webp/index.js
generated
vendored
Normal file
@@ -0,0 +1,84 @@
|
||||
'use strict';
|
||||
const execBuffer = require('exec-buffer');
|
||||
const isCwebpReadable = require('is-cwebp-readable');
|
||||
const cwebp = require('cwebp-bin');
|
||||
|
||||
module.exports = opts => buf => {
|
||||
opts = Object.assign({}, opts);
|
||||
|
||||
if (!Buffer.isBuffer(buf)) {
|
||||
return Promise.reject(new TypeError('Expected a buffer'));
|
||||
}
|
||||
|
||||
if (!isCwebpReadable(buf)) {
|
||||
return Promise.resolve(buf);
|
||||
}
|
||||
|
||||
const args = [
|
||||
'-quiet',
|
||||
'-mt'
|
||||
];
|
||||
|
||||
if (opts.preset) {
|
||||
args.push('-preset', opts.preset);
|
||||
}
|
||||
|
||||
if (opts.quality) {
|
||||
args.push('-q', opts.quality);
|
||||
}
|
||||
|
||||
if (opts.alphaQuality) {
|
||||
args.push('-alpha_q', opts.alphaQuality);
|
||||
}
|
||||
|
||||
if (opts.method) {
|
||||
args.push('-m', opts.method);
|
||||
}
|
||||
|
||||
if (opts.size) {
|
||||
args.push('-size', opts.size);
|
||||
}
|
||||
|
||||
if (opts.sns) {
|
||||
args.push('-sns', opts.sns);
|
||||
}
|
||||
|
||||
if (opts.filter) {
|
||||
args.push('-f', opts.filter);
|
||||
}
|
||||
|
||||
if (opts.autoFilter) {
|
||||
args.push('-af');
|
||||
}
|
||||
|
||||
if (opts.sharpness) {
|
||||
args.push('-sharpness', opts.sharpness);
|
||||
}
|
||||
|
||||
if (opts.lossless) {
|
||||
args.push('-lossless');
|
||||
}
|
||||
|
||||
if (opts.nearLossless) {
|
||||
args.push('-near_lossless', opts.nearLossless);
|
||||
}
|
||||
|
||||
if (opts.crop) {
|
||||
args.push('-crop', opts.crop.x, opts.crop.y, opts.crop.width, opts.crop.height);
|
||||
}
|
||||
|
||||
if (opts.resize) {
|
||||
args.push('-resize', opts.resize.width, opts.resize.height);
|
||||
}
|
||||
|
||||
args.push('-o', execBuffer.output, execBuffer.input);
|
||||
|
||||
return execBuffer({
|
||||
input: buf,
|
||||
bin: cwebp,
|
||||
args
|
||||
}).catch(err => {
|
||||
err.message = err.stderr || err.message;
|
||||
throw err;
|
||||
});
|
||||
};
|
||||
9
build/node_modules/imagemin-webp/license
generated
vendored
Normal file
9
build/node_modules/imagemin-webp/license
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
MIT License
|
||||
|
||||
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.
|
||||
89
build/node_modules/imagemin-webp/package.json
generated
vendored
Normal file
89
build/node_modules/imagemin-webp/package.json
generated
vendored
Normal file
@@ -0,0 +1,89 @@
|
||||
{
|
||||
"_from": "imagemin-webp",
|
||||
"_id": "imagemin-webp@4.1.0",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha1-7/0AFg2EVrlcveX9JsMtZLAxgGI=",
|
||||
"_location": "/imagemin-webp",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "tag",
|
||||
"registry": true,
|
||||
"raw": "imagemin-webp",
|
||||
"name": "imagemin-webp",
|
||||
"escapedName": "imagemin-webp",
|
||||
"rawSpec": "",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "latest"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"#USER",
|
||||
"/"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/imagemin-webp/-/imagemin-webp-4.1.0.tgz",
|
||||
"_shasum": "effd00160d8456b95cbde5fd26c32d64b0318062",
|
||||
"_spec": "imagemin-webp",
|
||||
"_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-webp/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"dependencies": {
|
||||
"cwebp-bin": "^4.0.0",
|
||||
"exec-buffer": "^3.0.0",
|
||||
"is-cwebp-readable": "^2.0.1"
|
||||
},
|
||||
"deprecated": false,
|
||||
"description": "WebP imagemin plugin",
|
||||
"devDependencies": {
|
||||
"ava": "*",
|
||||
"is-webp": "^1.0.0",
|
||||
"pify": "^3.0.0",
|
||||
"xo": "*"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=4"
|
||||
},
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"homepage": "https://github.com/imagemin/imagemin-webp#readme",
|
||||
"keywords": [
|
||||
"compress",
|
||||
"cwebp",
|
||||
"image",
|
||||
"imageminplugin",
|
||||
"img",
|
||||
"jpg",
|
||||
"minify",
|
||||
"optimize",
|
||||
"png",
|
||||
"tif",
|
||||
"webp"
|
||||
],
|
||||
"license": "MIT",
|
||||
"maintainers": [
|
||||
{
|
||||
"name": "Sindre Sorhus",
|
||||
"email": "sindresorhus@gmail.com",
|
||||
"url": "sindresorhus.com"
|
||||
},
|
||||
{
|
||||
"name": "Shinnosuke Watanabe",
|
||||
"url": "github.com/shinnn"
|
||||
}
|
||||
],
|
||||
"name": "imagemin-webp",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/imagemin/imagemin-webp.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "xo && ava"
|
||||
},
|
||||
"version": "4.1.0"
|
||||
}
|
||||
133
build/node_modules/imagemin-webp/readme.md
generated
vendored
Normal file
133
build/node_modules/imagemin-webp/readme.md
generated
vendored
Normal file
@@ -0,0 +1,133 @@
|
||||
# imagemin-webp [](https://travis-ci.org/imagemin/imagemin-webp) [](https://ci.appveyor.com/project/ShinnosukeWatanabe/imagemin-webp)
|
||||
|
||||
> WebP [imagemin](https://github.com/imagemin/imagemin) plugin
|
||||
|
||||
|
||||
## Install
|
||||
|
||||
```
|
||||
$ npm install imagemin-webp
|
||||
```
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
const imagemin = require('imagemin');
|
||||
const imageminWebp = require('imagemin-webp');
|
||||
|
||||
imagemin(['images/*.{jpg,png}'], 'build/images', {
|
||||
use: [
|
||||
imageminWebp({quality: 50})
|
||||
]
|
||||
}).then(() => {
|
||||
console.log('Images optimized');
|
||||
});
|
||||
```
|
||||
|
||||
|
||||
## API
|
||||
|
||||
### imageminWebp([options])(buffer)
|
||||
|
||||
#### options
|
||||
|
||||
Type: `Object`
|
||||
|
||||
##### preset
|
||||
|
||||
Type: `string`<br>
|
||||
Default: `default`
|
||||
|
||||
Preset setting, one of `default`, `photo`, `picture`, `drawing`, `icon` and `text`.
|
||||
|
||||
##### quality
|
||||
|
||||
Type: `number`<br>
|
||||
Default: `75`
|
||||
|
||||
Set quality factor between `0` and `100`.
|
||||
|
||||
##### alphaQuality
|
||||
|
||||
Type: `number`<br>
|
||||
Default: `100`
|
||||
|
||||
Set transparency-compression quality between `0` and `100`.
|
||||
|
||||
##### method
|
||||
|
||||
Type: `number`<br>
|
||||
Default: `4`
|
||||
|
||||
Specify the compression method to use, between `0` (fastest) and `6` (slowest). This parameter controls the trade off between encoding speed and the compressed file size and quality.
|
||||
|
||||
##### size
|
||||
|
||||
Type: `number`<br>
|
||||
|
||||
Set target size in bytes.
|
||||
|
||||
##### sns
|
||||
|
||||
Type: `number`<br>
|
||||
Default: `80`
|
||||
|
||||
Set the amplitude of spatial noise shaping between `0` and `100`.
|
||||
|
||||
##### filter
|
||||
|
||||
Type: `number`<br>
|
||||
|
||||
Set deblocking filter strength between `0` (off) and `100`.
|
||||
|
||||
##### autoFilter
|
||||
|
||||
Type: `boolean`<br>
|
||||
Default: `false`<br>
|
||||
|
||||
Adjust filter strength automatically.
|
||||
|
||||
##### sharpness
|
||||
|
||||
Type: `number`<br>
|
||||
Default: `0`
|
||||
|
||||
Set filter sharpness between `0` (sharpest) and `7` (least sharp).
|
||||
|
||||
##### lossless
|
||||
|
||||
Type: `boolean`<br>
|
||||
Default: `false`
|
||||
|
||||
Encode images losslessly.
|
||||
|
||||
##### nearLossless
|
||||
|
||||
Type: `number`<br>
|
||||
Default: `100`
|
||||
|
||||
Encode losslessly with an additional [lossy pre-processing step](https://groups.google.com/a/webmproject.org/forum/#!msg/webp-discuss/0GmxDmlexek/3ggyYsaYdFEJ), with a quality factor between `0` (maximum pre-processing) and `100` (same as `lossless`).
|
||||
|
||||
##### crop
|
||||
|
||||
Type: `Object { x: number, y: number, width: number, height: number }`
|
||||
|
||||
Crop the image.
|
||||
|
||||
##### resize
|
||||
|
||||
Type: `Object { width: number, height: number }`
|
||||
|
||||
Resize the image. Happens after `crop`.
|
||||
|
||||
#### buffer
|
||||
|
||||
Type: `Buffer`
|
||||
|
||||
Buffer to optimize.
|
||||
|
||||
|
||||
## License
|
||||
|
||||
MIT © [Imagemin](https://github.com/imagemin)
|
||||
Reference in New Issue
Block a user