Skip to content

Commit

Permalink
Improved readme
Browse files Browse the repository at this point in the history
  • Loading branch information
giovannicalo committed Oct 3, 2022
1 parent c118d7e commit 21a8aa4
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions readme.md
Expand Up @@ -70,26 +70,22 @@ const { Format, encode } = require("webp");

## API

### `Format.rgba`
### `Format.rgba = 0`

Value: 0
Standard RGBA format.

Standard RGBA format, supports both decoding and encoding.

### `Format.yuv`

Value: 1
### `Format.yuv = 1`

YUV I420 format, currently supports only decoding. Smaller and faster than RGBA, but less straightforward. When decoding, if the source WebP has odd dimensions, they will be rounded up to the nearest even number.

### `decode(data: Buffer, format = Format.rgba): Promise<Image>`
### `decode(data: Buffer, format: Format = Format.rgba): Promise<Image>`

Decodes the WebP image stored in the `data` buffer as `format`, which can be either `Format.rgba` or `Format.yuv`.
Decodes the WebP image stored in the `data` `Buffer` as `format`, which can be either `Format.rgba` or `Format.yuv`.

Returns a promise resolving to an object with `data`, `height`, `format` and `width` properties.

### `encode(image: Image, quality = 90): Promise<Buffer>`
### `encode(image: Image, quality: number = 90): Promise<Buffer>`

Encodes a raw `image` as WebP with the given `quality`. `image` must be an object with `data`, `height`, `format` and `width` properties. `image.format` currently has to be `Format.rgba`.

Returns a promise resolving to a buffer.
Returns a promise resolving to a `Buffer`.

0 comments on commit 21a8aa4

Please sign in to comment.