0.1.0 • Published 3 years ago

webp-animation-generator v0.1.0

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

Create WebP animation from sample images. You can use image data or canvas directly.

Important notice: this library is optimised only for web usage at the moment.

import { AnimationGenerator } from '../dist/main.js';

const instance = new AnimationGenerator();

await instance.init('/dist/worker.js');

const file1 = await (await fetch('/file-01.webp').then(resp => resp.blob())).arrayBuffer();
const file2 = await (await fetch('/file-02.webp').then(resp => resp.blob())).arrayBuffer();

instance.addFrame(new Uint8Array(file1), { delay: 1000 });
instance.addFrame(new Uint8Array(file2), { delay: 1000 });

const result = await instance.generate();

const blob = new Blob([result.buffer], { type: 'image/webp' });
const img = document.createElement('img');
img.src = URL.createObjectURL(blob);
document.body.appendChild(img)

instance.release();
0.1.0

3 years ago

0.0.2

3 years ago

0.0.1

3 years ago