is-file-animated

v1.0.2
Detects animated images from file handles e.g. Blob/File or fs.FileHandle
animated animated gif animated image animated png animated webp animation apng gif png and 2 more...

is-file-animated

npm ci standard standard version

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}.`)

License

MIT

npm i is-file-animated

Metadata

  • MIT
  • Whatever
  • Kagami Rosylight
  • released 12/18/2022

Downloads

Maintainers