JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 3
  • Score
    100M100P100Q92911F
  • License MIT

Detect whether an image (WebP, AVIF, APNG) is animated by inspecting its binary header.

Package Exports

  • @jiihpeeh/is-animated
  • @jiihpeeh/is-animated/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@jiihpeeh/is-animated) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

is-animated

Detect whether an image is animated by inspecting its binary header.

Supports APNG (animated PNG), animated GIF, animated WebP, and animated AVIF.
Pure JS, zero dependencies, works in browsers and Node.js.

Install

npm install is-animated

Usage

import { is_animated, detect_format } from 'is-animated';

const response = await fetch('https://example.com/image.webp');
const blob = await response.blob();
const bytes = new Uint8Array(await blob.slice(0, 4096).arrayBuffer());

is_animated(bytes);   // true | false
detect_format(bytes); // 'png' | 'gif' | 'webp' | 'avif' | 'unknown'

Only the first few KB are needed — the animation markers live in the file header.

API

is_animated(data: Uint8Array): boolean

Returns true if the image has multiple frames (is animated).

Format Detection method
APNG Scans for the acTL chunk after the PNG signature
GIF Counts image descriptors (0x2C) in the block structure
WebP Checks the VP8X chunk animation flag (bit 1) or looks for an ANIM chunk
AVIF Looks for moov or moof boxes in the ISOBMFF container

detect_format(data: Uint8Array): 'png' | 'gif' | 'webp' | 'avif' | 'unknown'

Returns the detected image format. Fast path — only reads the file signature.

Test

npm test

46 tests across 8 suites, including real encoded files generated by ffmpeg (lossy and lossless variants).

License

MIT