first commit
This commit is contained in:
77
build/node_modules/imagemin-jpeg-recompress/index.js
generated
vendored
Executable file
77
build/node_modules/imagemin-jpeg-recompress/index.js
generated
vendored
Executable file
@@ -0,0 +1,77 @@
|
||||
'use strict';
|
||||
const execBuffer = require('exec-buffer');
|
||||
const isJpg = require('is-jpg');
|
||||
const jpegRecompress = require('jpeg-recompress-bin');
|
||||
|
||||
module.exports = opts => buf => {
|
||||
opts = Object.assign({}, opts);
|
||||
|
||||
if (!Buffer.isBuffer(buf)) {
|
||||
return Promise.reject(new TypeError('Expected a buffer'));
|
||||
}
|
||||
|
||||
if (!isJpg(buf)) {
|
||||
return Promise.resolve(buf);
|
||||
}
|
||||
|
||||
const args = ['--quiet'];
|
||||
|
||||
if (opts.accurate) {
|
||||
args.push('--accurate');
|
||||
}
|
||||
|
||||
if (opts.quality) {
|
||||
args.push('--quality', opts.quality);
|
||||
}
|
||||
|
||||
if (opts.method) {
|
||||
args.push('--method', opts.method);
|
||||
}
|
||||
|
||||
if (opts.target) {
|
||||
args.push('--target', opts.target);
|
||||
}
|
||||
|
||||
if (opts.min) {
|
||||
args.push('--min', opts.min);
|
||||
}
|
||||
|
||||
if (opts.max) {
|
||||
args.push('--max', opts.max);
|
||||
}
|
||||
|
||||
if (opts.loops) {
|
||||
args.push('--loops', opts.loops);
|
||||
}
|
||||
|
||||
if (opts.defish) {
|
||||
args.push('--defish', opts.defish);
|
||||
}
|
||||
|
||||
if (opts.zoom) {
|
||||
args.push('--zoom', opts.zoom);
|
||||
}
|
||||
|
||||
if (opts.progressive === false) {
|
||||
args.push('--no-progressive');
|
||||
}
|
||||
|
||||
if (opts.subsample) {
|
||||
args.push('--subsample', opts.subsample);
|
||||
}
|
||||
|
||||
if (opts.strip !== false) {
|
||||
args.push('--strip');
|
||||
}
|
||||
|
||||
args.push(execBuffer.input, execBuffer.output);
|
||||
|
||||
return execBuffer({
|
||||
input: buf,
|
||||
bin: jpegRecompress,
|
||||
args
|
||||
}).catch(err => {
|
||||
err.message = err.stderr || err.message;
|
||||
throw err;
|
||||
});
|
||||
};
|
||||
21
build/node_modules/imagemin-jpeg-recompress/license
generated
vendored
Normal file
21
build/node_modules/imagemin-jpeg-recompress/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.
|
||||
93
build/node_modules/imagemin-jpeg-recompress/package.json
generated
vendored
Normal file
93
build/node_modules/imagemin-jpeg-recompress/package.json
generated
vendored
Normal file
@@ -0,0 +1,93 @@
|
||||
{
|
||||
"_args": [
|
||||
[
|
||||
"imagemin-jpeg-recompress@5.1.0",
|
||||
"/Users/asciidisco/Desktop/asciidisco.com/build"
|
||||
]
|
||||
],
|
||||
"_from": "imagemin-jpeg-recompress@5.1.0",
|
||||
"_id": "imagemin-jpeg-recompress@5.1.0",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha1-QbgpTsa2NqX8uuJ8kCSR+mTHEZg=",
|
||||
"_location": "/imagemin-jpeg-recompress",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "version",
|
||||
"registry": true,
|
||||
"raw": "imagemin-jpeg-recompress@5.1.0",
|
||||
"name": "imagemin-jpeg-recompress",
|
||||
"escapedName": "imagemin-jpeg-recompress",
|
||||
"rawSpec": "5.1.0",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "5.1.0"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/imagemin-jpeg-recompress/-/imagemin-jpeg-recompress-5.1.0.tgz",
|
||||
"_spec": "5.1.0",
|
||||
"_where": "/Users/asciidisco/Desktop/asciidisco.com/build",
|
||||
"author": {
|
||||
"name": "Shinnosuke Watanabe",
|
||||
"url": "github.com/shinnn"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/imagemin/imagemin-jpeg-recompress/issues"
|
||||
},
|
||||
"dependencies": {
|
||||
"exec-buffer": "^3.0.0",
|
||||
"is-jpg": "^1.0.0",
|
||||
"jpeg-recompress-bin": "^3.0.1"
|
||||
},
|
||||
"description": "jpeg-recompress imagemin plugin",
|
||||
"devDependencies": {
|
||||
"ava": "*",
|
||||
"exif": "^0.6.0",
|
||||
"is-progressive": "^1.0.1",
|
||||
"pify": "^2.3.0",
|
||||
"xo": "*"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=4"
|
||||
},
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"homepage": "https://github.com/imagemin/imagemin-jpeg-recompress#readme",
|
||||
"keywords": [
|
||||
"compress",
|
||||
"image",
|
||||
"imageminplugin",
|
||||
"img",
|
||||
"jpeg",
|
||||
"jpeg-recompress",
|
||||
"jpg",
|
||||
"minify",
|
||||
"optimize"
|
||||
],
|
||||
"license": "MIT",
|
||||
"maintainers": [
|
||||
{
|
||||
"name": "Sindre Sorhus",
|
||||
"email": "sindresorhus@gmail.com",
|
||||
"url": "sindresorhus.com"
|
||||
},
|
||||
{
|
||||
"name": "Kevin Mårtensson",
|
||||
"email": "kevinmartensson@gmail.com",
|
||||
"url": "github.com/kevva"
|
||||
}
|
||||
],
|
||||
"name": "imagemin-jpeg-recompress",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/imagemin/imagemin-jpeg-recompress.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "xo && ava"
|
||||
},
|
||||
"version": "5.1.0",
|
||||
"xo": {
|
||||
"esnext": true
|
||||
}
|
||||
}
|
||||
121
build/node_modules/imagemin-jpeg-recompress/readme.md
generated
vendored
Executable file
121
build/node_modules/imagemin-jpeg-recompress/readme.md
generated
vendored
Executable file
@@ -0,0 +1,121 @@
|
||||
# imagemin-jpeg-recompress [](https://travis-ci.org/imagemin/imagemin-jpeg-recompress) [](https://ci.appveyor.com/project/ShinnosukeWatanabe/imagemin-jpeg-recompress)
|
||||
|
||||
> jpeg-recompress imagemin plugin
|
||||
|
||||
|
||||
## Install
|
||||
|
||||
```
|
||||
$ npm install --save imagemin-jpeg-recompress
|
||||
```
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
const imagemin = require('imagemin');
|
||||
const imageminJpegRecompress = require('imagemin-jpeg-recompress');
|
||||
|
||||
imagemin(['images/*.jpg'], 'build/images', {
|
||||
plugins: [
|
||||
imageminJpegRecompress()
|
||||
]
|
||||
}).then(() => {
|
||||
console.log('Images optimized');
|
||||
});
|
||||
```
|
||||
|
||||
|
||||
## API
|
||||
|
||||
### imageminJpegRecompress([options])(buffer)
|
||||
|
||||
#### options
|
||||
|
||||
##### accurate
|
||||
|
||||
Type: `boolean`<br>
|
||||
Default: `false`
|
||||
|
||||
Favor accuracy over speed.
|
||||
|
||||
##### quality
|
||||
|
||||
Type: `string`<br>
|
||||
Default: `medium`
|
||||
|
||||
Set a quality preset. Available presets: `low`, `medium`, `high` and `veryhigh`.
|
||||
|
||||
##### method
|
||||
|
||||
Type: `string`<br>
|
||||
Default: `ssim`
|
||||
|
||||
Set [comparison method](https://github.com/danielgtaylor/jpeg-archive#image-comparison-metrics). Available methods: `mpe`, `ssim`, `ms-ssim` and `smallfry`.
|
||||
|
||||
##### target
|
||||
|
||||
Type: `number`<br>
|
||||
Default: `0.9999`
|
||||
|
||||
Set target quality.
|
||||
|
||||
##### min
|
||||
|
||||
Type: `number`<br>
|
||||
Default: `40`
|
||||
|
||||
Minimum JPEG quality.
|
||||
|
||||
##### max
|
||||
|
||||
Type: `number`<br>
|
||||
Default: `95`
|
||||
|
||||
Maximum JPEG quality.
|
||||
|
||||
##### loops
|
||||
|
||||
Type: `number`<br>
|
||||
Default: `6`
|
||||
|
||||
Set the number of attempts.
|
||||
|
||||
##### defish
|
||||
|
||||
Type: `number`<br>
|
||||
Default: `0`
|
||||
|
||||
Set defish strength.
|
||||
|
||||
##### progressive
|
||||
|
||||
Type: `boolean`<br>
|
||||
Default: `true`
|
||||
|
||||
Enable progressive encoding.
|
||||
|
||||
##### subsample
|
||||
|
||||
Type: `string`<br>
|
||||
Default: `default`
|
||||
|
||||
Set subsampling method. Available values: `default`, `disable`.
|
||||
|
||||
##### strip
|
||||
|
||||
Type: `boolean`<br>
|
||||
Default: `true`
|
||||
|
||||
Strips metadata, such as EXIF data.
|
||||
|
||||
#### buffer
|
||||
|
||||
Type: `buffer`
|
||||
|
||||
Buffer to optimize.
|
||||
|
||||
|
||||
## License
|
||||
|
||||
MIT © [imagemin](https://github.com/imagemin)
|
||||
Reference in New Issue
Block a user