imagemin-mozjpeg (#38202)

* imagemin-mozjpeg

* fix test since imagemin v8 is not merged

* fix formatting
This commit is contained in:
Jeff Chan 2019-09-25 07:03:07 +08:00 committed by Ben Lichtman
parent 1373ee1260
commit f952702933
4 changed files with 177 additions and 0 deletions

View File

@ -0,0 +1,31 @@
import imagemin = require('imagemin');
import imageminMozjpeg = require('imagemin-mozjpeg');
imagemin([ '*.jpg' ]);
/* Comment out since imagemin 8 PR is not yet merged
imagemin([ '*.jpg' ], {
destination: 'something',
plugins: [
imageminMozjpeg(),
imageminMozjpeg({
quality: 10,
progressive: true,
targa: false,
revert: false,
fastCrush: true,
dcScanOpt: 1,
trellis: true,
trellisDC: true,
tune: 'hvs-psnr',
overshoot: true,
arithmetic: true,
dct: 'int',
quantBaseline: false,
quantTable: 1,
smooth: 5,
maxMemory: 1024,
sample: [ '2x1', '3x2' ],
}),
],
});
*/

122
types/imagemin-mozjpeg/index.d.ts vendored Normal file
View File

@ -0,0 +1,122 @@
// Type definitions for imagemin-mozjpeg 8.0
// Project: https://github.com/imagemin/imagemin-mozjpeg#readme
// Definitions by: Jeff Chan <https://github.com/hkjeffchan>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
import { Plugin } from 'imagemin';
declare function imageminMozjpeg(options?: imageminMozjpeg.Options): Plugin;
declare namespace imageminMozjpeg {
interface Options {
/** Compression quality, in range 0 (worst) to 100 (perfect). */
quality?: number;
/**
* false creates baseline JPEG file.
* @default true
*/
progressive?: boolean;
/**
* Input file is Targa format (usually not needed).
* @default false
*/
targa?: boolean;
/**
* Revert to standard defaults instead of mozjpeg defaults.
* @default false
*/
revert?: boolean;
/**
* Disable progressive scan optimization.
* @default false
*/
fastCrush?: boolean;
/**
* Set DC scan optimization mode.
* 0 One scan for all components
* 1 One scan per component
* 2 Optimize between one scan for all components and one scan for 1st component plus one scan for remaining components
* @default 1
*/
dcScanOpt?: number;
/**
* Trellis optimization.
* @default true
*
*/
trellis?: boolean;
/**
* Trellis optimization of DC coefficients.
* @default true
*/
trellisDC?: boolean;
/**
* Set Trellis optimization method. Available methods: psnr, hvs-psnr, ssim, ms-ssim
* @default 'hvs-psnr'
*/
tune?: 'psnr' | 'hvs-psnr' | 'ssim' | 'ms-ssim';
/**
* Black-on-white deringing via overshoot.
* @default true
*/
overshoot?: boolean;
/**
* Use arithmetic coding.
* @default false
*/
arithmetic?: boolean;
/**
* Set DCT method:
* int Use integer DCT
* fast Use fast integer DCT (less accurate)
* float Use floating-point DCT
* @default 'int'
*/
dct?: 'int' | 'fast' | 'float';
/**
* Use 8-bit quantization table entries for baseline JPEG compatibility.
* @default false
*/
quantBaseline?: boolean;
/**
* Use predefined quantization table.
* 0 JPEG Annex K
* 1 Flat
* 2 Custom, tuned for MS-SSIM
* 3 ImageMagick table by N. Robidoux
* 4 Custom, tuned for PSNR-HVS
* 5 Table from paper by Klein, Silverstein and Carney
*/
quantTable?: number;
/**
* Set the strength of smooth dithered input. (1...100)
*/
smooth?: number;
/**
* Set the maximum memory to use in kilobytes.
*/
maxMemory?: number;
/**
* Set component sampling factors. Each item should be in the format HxV, for example 2x1.
*/
sample?: string[];
}
}
export = imageminMozjpeg;

View File

@ -0,0 +1,23 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictFunctionTypes": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"imagemin-mozjpeg-tests.ts"
]
}

View File

@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }