libavif-wasm
TypeScript icon, indicating that this package has built-in type declarations

0.1.13 • Public • Published

WIP

fork https://github.com/saschazar21/webassembly

  • [x] support ts
  • [x] support browser and node
  • [x] support more encode/decode options
  • [ ] not support encode from file, convert file to pixels is very complex, so you should use other 3rd lib.

install

npm i libavif-wasm

usage

import { init, decode, encode, destroy, AvifPixelFormat } from "../dist";

await init();

const file = readFileSync(join(root, "img", "fixture-yuv420-8bit.avif"));
const image = await decode(file, { alphaPresent: true });
const { data, width, height, channel } = image;
expect(data.length).toEqual(width * height * channel);
import { checkImage } from 'check-image-type';

const encodeFile = await encode(data, width, height, channel, {
      speed: 3,
      minQuantizer: 40,
      maxQuantizer: 50,
      minQuantizerAlpha: 20,
      maxQuantizerAlpha: 30,
      avifPixelFormat: AvifPixelFormat.AVIF_PIXEL_FORMAT_YUV444,
});
const imageType = checkImage(encodeFile);
expect(imageType?.ext === "avif");

destroy();

API

init


destroy


encode


decode


Package Sidebar

Install

npm i libavif-wasm

Weekly Downloads

16

Version

0.1.13

License

MIT

Unpacked Size

28.7 MB

Total Files

16

Last publish

Collaborators

  • ahaoboy