Skip to content

Commit

Permalink
Require Node.js 14
Browse files Browse the repository at this point in the history
  • Loading branch information
sindresorhus committed Jan 27, 2023
1 parent a366d9c commit 4f1d39f
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 44 deletions.
18 changes: 3 additions & 15 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
}
}
51 changes: 23 additions & 28 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,33 +2,28 @@

> WebP [imagemin](https://github.com/imagemin/imagemin) plugin

## Install

```sh
npm install imagemin-webp
```
$ npm install imagemin-webp
```


## Usage

```js
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)
Expand All @@ -41,75 +36,75 @@ Type: `object`

##### preset

Type: `string`<br>
Type: `string`\
Default: `default`

Preset setting, one of `default`, `photo`, `picture`, `drawing`, `icon` and `text`.

##### quality

Type: `number`<br>
Type: `number`\
Default: `75`

Set quality factor between `0` and `100`.

##### alphaQuality

Type: `number`<br>
Type: `number`\
Default: `100`

Set transparency-compression quality between `0` and `100`.

##### method

Type: `number`<br>
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`<br>
Type: `number`

Set target size in bytes.

##### sns

Type: `number`<br>
Type: `number`\
Default: `50`

Set the amplitude of spatial noise shaping between `0` and `100`.

##### filter

Type: `number`<br>
Type: `number`

Set deblocking filter strength between `0` (off) and `100`.

##### autoFilter

Type: `boolean`<br>
Default: `false`<br>
Type: `boolean`\
Default: `false`

Adjust filter strength automatically.

##### sharpness

Type: `number`<br>
Type: `number`\
Default: `0`

Set filter sharpness between `0` (sharpest) and `7` (least sharp).

##### lossless

Type: `boolean | number`<br>
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`<br>
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`).
Expand All @@ -128,8 +123,8 @@ Resize the image. Happens after `crop`.

##### metadata

Type: `string | string[]`<br>
Default: `none`<br>
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.
Expand Down
2 changes: 1 addition & 1 deletion test.js
Original file line number Diff line number Diff line change
@@ -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';
Expand Down

0 comments on commit 4f1d39f

Please sign in to comment.