libavif-wasm
v0.1.13
Published
Library for encode and decode avif image with libavif & wasm
Downloads
16
Maintainers
Readme
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