From f952702933302a2a4332c04fea2ead28f7f32b62 Mon Sep 17 00:00:00 2001 From: Jeff Chan <695282+hkjeffchan@users.noreply.github.com> Date: Wed, 25 Sep 2019 07:03:07 +0800 Subject: [PATCH] imagemin-mozjpeg (#38202) * imagemin-mozjpeg * fix test since imagemin v8 is not merged * fix formatting --- .../imagemin-mozjpeg-tests.ts | 31 +++++ types/imagemin-mozjpeg/index.d.ts | 122 ++++++++++++++++++ types/imagemin-mozjpeg/tsconfig.json | 23 ++++ types/imagemin-mozjpeg/tslint.json | 1 + 4 files changed, 177 insertions(+) create mode 100644 types/imagemin-mozjpeg/imagemin-mozjpeg-tests.ts create mode 100644 types/imagemin-mozjpeg/index.d.ts create mode 100644 types/imagemin-mozjpeg/tsconfig.json create mode 100644 types/imagemin-mozjpeg/tslint.json diff --git a/types/imagemin-mozjpeg/imagemin-mozjpeg-tests.ts b/types/imagemin-mozjpeg/imagemin-mozjpeg-tests.ts new file mode 100644 index 0000000000..5a542ccba0 --- /dev/null +++ b/types/imagemin-mozjpeg/imagemin-mozjpeg-tests.ts @@ -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' ], + }), + ], +}); +*/ diff --git a/types/imagemin-mozjpeg/index.d.ts b/types/imagemin-mozjpeg/index.d.ts new file mode 100644 index 0000000000..5c831752be --- /dev/null +++ b/types/imagemin-mozjpeg/index.d.ts @@ -0,0 +1,122 @@ +// Type definitions for imagemin-mozjpeg 8.0 +// Project: https://github.com/imagemin/imagemin-mozjpeg#readme +// Definitions by: Jeff Chan +// 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; diff --git a/types/imagemin-mozjpeg/tsconfig.json b/types/imagemin-mozjpeg/tsconfig.json new file mode 100644 index 0000000000..82dcbe261a --- /dev/null +++ b/types/imagemin-mozjpeg/tsconfig.json @@ -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" + ] +} diff --git a/types/imagemin-mozjpeg/tslint.json b/types/imagemin-mozjpeg/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/imagemin-mozjpeg/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }