Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/node-libraries/wasm-webp-encoder
https://github.com/node-libraries/wasm-webp-encoder
Last synced: about 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/node-libraries/wasm-webp-encoder
- Owner: node-libraries
- Created: 2021-11-29T12:41:46.000Z (about 3 years ago)
- Default Branch: master
- Last Pushed: 2024-02-14T12:57:00.000Z (11 months ago)
- Last Synced: 2024-03-15T13:22:17.780Z (10 months ago)
- Language: TypeScript
- Size: 63.5 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# @node-libraries/wasm-webp-encoder
# Overview
Provides the ability to encode WebP using WebAssembly and WebWorker.
Remix(esbuild) and Next.js(webpack) are supported.
# types
```ts
encode(params:{data: BufferSource, width: number, height: number, quality?: number}): Promise
``````ts
encode(params:{data: ImageData, quality?: number}): Promise
```# usage
```ts
import { encode } from '@node-libraries/wasm-webp-encoder';// Next.js(webpack)
const encodedValue = await encode({ data: ctx.getImageData(0, 0, img.width, img.height) });
const encodedValue2 = await encode({ data: arrayBuffer, width, height });// Remix(esbuild)
// Files need to be installed manually
// node_modules/@node-libraries/wasm-webp-encoder/dist =>
// public/webp/worker.js
// public/webp/webp.js
// public/webp/webp.wasm
const encodedValue3 = await encode({ data: arrayBuffer, width, height, worker: '/webp/worker.js' });
```# Sample when used with Next.js
- https://github.com/SoraKumo001/next-webp