webp-animation-info
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

webp-animation-info

A library to calculate animation information for WebP files in the browser.

Usage

Use either the default import or destructure.

import { webPAnimationInfo } from "webp-animation-info";
import webPAnimationInfo from "webp-animation-info";

Then call with a file as argument and receive a promise which may resolve to a results object.

webPAnimationInfo(event.target.files?.[0])
  .then((results) => {
    console.log(`${results.isAnimated}
${results.loops}
${results.totalDuration}`); // if isAnimated is true, 0 value for loops means infinite loops
    results.frameDurations.forEach((frameDuration) => {
      console.log(`${frameDuration}`);
    });
  })
  .catch((error) => {
    console.error(error); // the calculation may encounter and throw errors
  });

Package Sidebar

Install

npm i webp-animation-info

Weekly Downloads

11

Version

1.0.1

License

MIT

Unpacked Size

18.3 kB

Total Files

25

Last publish

Collaborators

  • rachit-sharma