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 GIF, animated WebP, animated AVIF, and animated JPEG XL (JXL).
Pure JS, zero dependencies, works in browsers and Node.js.
Installation
npm install @jiihpeeh/is-animatedUsage
import { is_animated_blob, detect_format_blob } from 'is-animated';
const blob = await (await fetch('https://example.com/image.webp')).blob();
await is_animated_blob(blob); // true | false
await detect_format_blob(blob); // 'webp'Only the first few KB are needed — the animation markers live in the file header.
API
is_animated_blob(blob: Blob, size?: number): Promise<boolean>
Convenience wrapper — reads the first size bytes from a Blob and checks for animation. size defaults to DEFAULT_HEADER_SIZE (4096).
import { is_animated_blob, DEFAULT_HEADER_SIZE } from 'is-animated';
await is_animated_blob(blob); // 4096 bytes
await is_animated_blob(blob, 8192); // customdetect_format_blob(blob: Blob, size?: number): Promise<'png' | 'gif' | 'webp' | 'avif' | 'jxl' | 'unknown'>
Same as above but returns the detected image format.
is_animated(data: Uint8Array): boolean
Low-level — accepts a Uint8Array header. Useful if you already have the bytes.
| 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 |
| JXL | Parses the codestream header to read the have_animation flag (raw codestream); counts jxlp boxes (container format) |
detect_format(data: Uint8Array): 'png' | 'gif' | 'webp' | 'avif' | 'jxl' | 'unknown'
Low-level — detects format from raw bytes.
Individual format checkers
Each format's animated check is also exported for direct use:
import {
isAPNG,
isAnimatedGIF,
isAnimatedWebP,
isAnimatedAVIF,
isAnimatedJXL,
isJXL,
} from 'is-animated';Test
npm test57 tests across 9 suites, including real encoded files generated by ffmpeg (lossy and lossless variants) and cjxl for JXL.
License
MIT