From 4f1d39f104c744d72d63f8a82d781e49a0bc4d93 Mon Sep 17 00:00:00 2001 From: Sindre Sorhus Date: Fri, 27 Jan 2023 13:30:33 +0700 Subject: [PATCH] Require Node.js 14 --- package.json | 18 +++--------------- readme.md | 51 +++++++++++++++++++++++---------------------------- test.js | 2 +- 3 files changed, 27 insertions(+), 44 deletions(-) diff --git a/package.json b/package.json index 81ca671..d97c425 100644 --- a/package.json +++ b/package.json @@ -6,20 +6,8 @@ "repository": "imagemin/imagemin-webp", "type": "module", "exports": "./index.js", - "author": { - "name": "Kevin MÃ¥rtensson", - "email": "kevinmartensson@gmail.com", - "url": "github.com/kevva" - }, - "maintainers": [ - { - "name": "Sindre Sorhus", - "email": "sindresorhus@gmail.com", - "url": "sindresorhus.com" - } - ], "engines": { - "node": "^14.13.1 || >=16.0.0" + "node": ">=14.16" }, "scripts": { "test": "xo && ava" @@ -46,8 +34,8 @@ "is-cwebp-readable": "^3.0.0" }, "devDependencies": { - "ava": "^3.8.0", + "ava": "^5.1.1", "is-webp": "^2.0.0", - "xo": "^0.47.0" + "xo": "^0.53.1" } } diff --git a/readme.md b/readme.md index 9571071..ae44df0 100644 --- a/readme.md +++ b/readme.md @@ -2,13 +2,11 @@ > WebP [imagemin](https://github.com/imagemin/imagemin) plugin - ## Install +```sh +npm install imagemin-webp ``` -$ npm install imagemin-webp -``` - ## Usage @@ -16,19 +14,16 @@ $ npm install imagemin-webp import imagemin from 'imagemin'; import imageminWebp from 'imagemin-webp'; -(async () => { - await imagemin(['images/*.{jpg,png}'], { - destination: 'build/images', - plugins: [ - imageminWebp({quality: 50}) - ] - }); +await imagemin(['images/*.{jpg,png}'], { + destination: 'build/images', + plugins: [ + imageminWebp({quality: 50}) + ] +}); - console.log('Images optimized'); -})(); +console.log('Images optimized'); ``` - ## API ### imageminWebp(options?)(buffer) @@ -41,75 +36,75 @@ Type: `object` ##### preset -Type: `string`
+Type: `string`\ Default: `default` Preset setting, one of `default`, `photo`, `picture`, `drawing`, `icon` and `text`. ##### quality -Type: `number`
+Type: `number`\ Default: `75` Set quality factor between `0` and `100`. ##### alphaQuality -Type: `number`
+Type: `number`\ Default: `100` Set transparency-compression quality between `0` and `100`. ##### method -Type: `number`
+Type: `number`\ 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`
+Type: `number` Set target size in bytes. ##### sns -Type: `number`
+Type: `number`\ Default: `50` Set the amplitude of spatial noise shaping between `0` and `100`. ##### filter -Type: `number`
+Type: `number` Set deblocking filter strength between `0` (off) and `100`. ##### autoFilter -Type: `boolean`
-Default: `false`
+Type: `boolean`\ +Default: `false` Adjust filter strength automatically. ##### sharpness -Type: `number`
+Type: `number`\ Default: `0` Set filter sharpness between `0` (sharpest) and `7` (least sharp). ##### lossless -Type: `boolean | number`
+Type: `boolean | number`\ Default: `false` Encode images losslessly. If set to a number, activates lossless preset with given level between `0` (fastest, larger files) and `9` (slowest, smaller files). ##### nearLossless -Type: `number`
+Type: `number`\ 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`). @@ -128,8 +123,8 @@ Resize the image. Happens after `crop`. ##### metadata -Type: `string | string[]`
-Default: `none`
+Type: `string | string[]`\ +Default: `none`\ Values: `all` `none` `exif` `icc` `xmp` A list of metadata to copy from the input to the output if present. diff --git a/test.js b/test.js index 4f8f297..afce075 100644 --- a/test.js +++ b/test.js @@ -1,4 +1,4 @@ -import {promises as fs} from 'node:fs'; +import fs from 'node:fs/promises'; import isWebP from 'is-webp'; import test from 'ava'; import imageminWebp from './index.js';