first commit
This commit is contained in:
43
build/node_modules/imagemin-guetzli/index.js
generated
vendored
Normal file
43
build/node_modules/imagemin-guetzli/index.js
generated
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
'use strict';
|
||||
const execBuffer = require('exec-buffer');
|
||||
const isPng = require('is-png');
|
||||
const isJpg = require('is-jpg');
|
||||
const isInt = require('number-is-integer');
|
||||
const guetzli = require('guetzli');
|
||||
|
||||
module.exports = opts => buf => {
|
||||
opts = Object.assign({}, opts);
|
||||
|
||||
if (!Buffer.isBuffer(buf)) {
|
||||
return Promise.reject(new TypeError('Expected a buffer'));
|
||||
}
|
||||
|
||||
if (!isPng(buf) && !isJpg(buf)) {
|
||||
return Promise.resolve(buf);
|
||||
}
|
||||
|
||||
const args = [];
|
||||
|
||||
if (isInt(opts.quality) && opts.quality >= 0 && opts.quality <= 100) {
|
||||
args.push('--quality', opts.quality);
|
||||
}
|
||||
|
||||
if (isInt(opts.memlimit) && opts.memlimit > 0) {
|
||||
args.push('--memlimit', opts.memlimit);
|
||||
}
|
||||
|
||||
if (opts.nomemlimit) {
|
||||
args.push('--nomemlimit');
|
||||
}
|
||||
|
||||
args.push(execBuffer.input, execBuffer.output);
|
||||
|
||||
return execBuffer({
|
||||
input: buf,
|
||||
bin: guetzli,
|
||||
args
|
||||
}).catch(err => {
|
||||
err.message = err.stderr || err.message;
|
||||
throw err;
|
||||
});
|
||||
};
|
||||
21
build/node_modules/imagemin-guetzli/license
generated
vendored
Normal file
21
build/node_modules/imagemin-guetzli/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.
|
||||
94
build/node_modules/imagemin-guetzli/package.json
generated
vendored
Normal file
94
build/node_modules/imagemin-guetzli/package.json
generated
vendored
Normal file
@@ -0,0 +1,94 @@
|
||||
{
|
||||
"_from": "imagemin-guetzli",
|
||||
"_id": "imagemin-guetzli@1.0.0",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha1-a/+00dv/7WGTChVW7Jr2s/M97Dk=",
|
||||
"_location": "/imagemin-guetzli",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "tag",
|
||||
"registry": true,
|
||||
"raw": "imagemin-guetzli",
|
||||
"name": "imagemin-guetzli",
|
||||
"escapedName": "imagemin-guetzli",
|
||||
"rawSpec": "",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "latest"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"#USER",
|
||||
"/"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/imagemin-guetzli/-/imagemin-guetzli-1.0.0.tgz",
|
||||
"_shasum": "6bffb4d1dbffed61930a1556ec9af6b3f33dec39",
|
||||
"_spec": "imagemin-guetzli",
|
||||
"_where": "/Users/asciidisco/Desktop/asciidisco.com/build",
|
||||
"author": {
|
||||
"name": "Brad Baris",
|
||||
"email": "brad@nomadspaceship.com",
|
||||
"url": "github.com/bradbaris"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/imagemin/imagemin-guetzli/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"dependencies": {
|
||||
"exec-buffer": "^3.1.0",
|
||||
"guetzli": "^1.0.0",
|
||||
"is-jpg": "^1.0.0",
|
||||
"is-png": "^1.1.0",
|
||||
"number-is-integer": "^1.0.1"
|
||||
},
|
||||
"deprecated": false,
|
||||
"description": "Guetzli imagemin plugin",
|
||||
"devDependencies": {
|
||||
"ava": "*",
|
||||
"pify": "^2.3.0",
|
||||
"xo": "*"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=4"
|
||||
},
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"homepage": "https://github.com/imagemin/imagemin-guetzli#readme",
|
||||
"keywords": [
|
||||
"compress",
|
||||
"image",
|
||||
"imageminplugin",
|
||||
"img",
|
||||
"minify",
|
||||
"optimize",
|
||||
"png",
|
||||
"jpg",
|
||||
"photo",
|
||||
"guetzli"
|
||||
],
|
||||
"license": "MIT",
|
||||
"maintainers": [
|
||||
{
|
||||
"name": "Sindre Sorhus",
|
||||
"email": "sindresorhus@gmail.com",
|
||||
"url": "sindresorhus.com"
|
||||
},
|
||||
{
|
||||
"name": "Shinnosuke Watanabe",
|
||||
"url": "github.com/shinnn"
|
||||
},
|
||||
{
|
||||
"name": "Kevin Mårtensson",
|
||||
"email": "kevinmartensson@gmail.com",
|
||||
"url": "github.com/kevva"
|
||||
}
|
||||
],
|
||||
"name": "imagemin-guetzli",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/imagemin/imagemin-guetzli.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "xo && ava"
|
||||
},
|
||||
"version": "1.0.0"
|
||||
}
|
||||
93
build/node_modules/imagemin-guetzli/readme.md
generated
vendored
Normal file
93
build/node_modules/imagemin-guetzli/readme.md
generated
vendored
Normal file
@@ -0,0 +1,93 @@
|
||||
# imagemin-guetzli [](https://travis-ci.org/imagemin/imagemin-guetzli) [](https://ci.appveyor.com/project/bradbaris/imagemin-guetzli)
|
||||
|
||||
> [Guetzli](https://github.com/google/guetzli) imagemin plugin
|
||||
|
||||
> Guetzli is a JPEG encoder that aims for excellent compression density at high visual quality. Guetzli-generated images are typically 20-30% smaller than images of equivalent quality generated by libjpeg. Guetzli generates only sequential (nonprogressive) JPEGs due to faster decompression speeds they offer.
|
||||
|
||||
|
||||
## Install
|
||||
|
||||
```
|
||||
$ npm install --save imagemin-guetzli
|
||||
```
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
const imagemin = require('imagemin');
|
||||
const imageminGuetzli = require('imagemin-guetzli');
|
||||
|
||||
imagemin(['images/*.{png,jpg}'], 'build/images', {
|
||||
use: [
|
||||
imageminGuetzli({quality: 95})
|
||||
]
|
||||
}).then(() => {
|
||||
console.log('Images optimized');
|
||||
});
|
||||
```
|
||||
|
||||
## Usage (gulp-imagemin)
|
||||
|
||||
```js
|
||||
const gulp = require('gulp');
|
||||
const imagemin = require('gulp-imagemin');
|
||||
const imageminGuetzli = require('imagemin-guetzli');
|
||||
|
||||
gulp.task('default', () =>
|
||||
gulp.src('images/*')
|
||||
.pipe(imagemin([imageminGuetzli()]))
|
||||
.pipe(gulp.dest('dist/images'))
|
||||
);
|
||||
```
|
||||
|
||||
### Notes
|
||||
|
||||
Guetzli uses a large amount of memory. You should provide **300MB of memory per 1MPix** of the input image.
|
||||
|
||||
Guetzli uses a significant amount of CPU time. You should count on using about **1 minute of CPU per 1MPix** of input image.
|
||||
|
||||
Guetzli assumes that input is in **sRGB profile** with a **gamma of 2.2**. Guetzli will ignore any color-profile metadata in the image.
|
||||
|
||||
Guetzli is designed to work on high quality images (e.g. that haven't
|
||||
been already compressed with other JPEG encoders). While it will work on other
|
||||
images too, results will be poorer. You can try compressing an enclosed [sample
|
||||
high quality
|
||||
image](https://github.com/google/guetzli/releases/download/v0/bees.png).
|
||||
|
||||
Guetzli converts PNG/JPG to JPG. When using this plugin or guetzli-bin CLI, the original filename+ext is used as the output, although the image format has changed. You have to rename the file with the correct file extension (JPG) yourself afterwards.
|
||||
|
||||
## API
|
||||
|
||||
### imageminGuetzli([options])(buffer)
|
||||
|
||||
#### options
|
||||
|
||||
Type: `object`
|
||||
|
||||
##### quality
|
||||
|
||||
Type: `number` (0–100)<br>
|
||||
Default: `95`
|
||||
|
||||
Set quality in units equivalent to libjpeg quality. As per guetzli function and purpose, it is not recommended to go below `84`.
|
||||
|
||||
Please note that JPEG images do not support alpha channel (transparency). If the input is a PNG with an alpha channel, it will be overlaid on black background before encoding.
|
||||
|
||||
##### memlimit
|
||||
|
||||
Type: `number`<br>
|
||||
Default: `6000`
|
||||
|
||||
Memory limit in MB. Guetzli will fail if unable to stay under the limit.
|
||||
Note: Currently, in `imagemin-guetzli`, this will fail silently as the error is not passed along.
|
||||
|
||||
##### nomemlimit
|
||||
|
||||
Type: `boolean`<br>
|
||||
|
||||
Do not limit memory usage.
|
||||
|
||||
## License
|
||||
|
||||
MIT © [imagemin](https://github.com/imagemin)
|
||||
Reference in New Issue
Block a user