is-file-animated
v1.0.2
Published
Detects animated images from file handles e.g. Blob/File or fs.FileHandle
Downloads
7,244
Maintainers
Readme
is-file-animated
is-file-animated is a simple library for detecting animated GIF/PNG/WebP images from Blob/File or fs.FileHandle.
Install
npm install is-file-animated
Example
On browsers and similar environments:
import isAnimated from 'https://cdn.jsdelivr.net/npm/is-file-animated/+esm'
const response = await fetch(url)
const blob = await response.blob()
const answer = await isAnimated(blob) ? 'Yes' : 'No'
console.log(`Is "${url}" animated? ${answer}.`)
On Node.js:
import { open } from 'fs/promises'
import isAnimated from 'is-file-animated'
const filename = process.argv[2]
const handle = await open(filename)
const answer = await isAnimated(handle) ? 'Yes' : 'No'
console.log(`Is "${filename}" animated? ${answer}.`)