Oxipng WebAssembly Codec
npm install @wasm-codecs/oxipng
Requirements:
- Node.js 10 or later
import encode from '@wasm-codecs/oxipng';
(async () => {
const encodedImage = await encode(image, encodeOptions);
})();
Returns a buffer containing the compressed image data.
Buffer of a PNG image.
All encoding options are optional and fall back to the default values.
type EncodeOptions = {
level?: number;
}
import fs from 'fs';
import encode from '@wasm-codecs/oxipng';
// read input image as a buffer
const data = fs.readFileSync('in.png');
// encode the image using @wasm-codecs/oxipng
const output = encode(data);
// save the image to the file system
fs.writeFileSync('out.png', output);
Licensed under the MIT license.
© Copyright Cyril Wanner