sindresorhus / file-type

Detect the file type of a file, stream, or data
MIT License
3.73k stars 354 forks source link

Detect animated image #686

Open styfle opened 3 weeks ago

styfle commented 3 weeks ago

Description

I see that APNG support was added in PR https://github.com/sindresorhus/file-type/pull/215 which is great to detect the difference between a static PNG and animated PNG. This works great because they each have their own file extension and mime type.

However, I can't seem to find any way to differentiate static vs animated WebP images because the file extension and mime type are the same for both.

Is that possible using this package? If not, consider this a feature request 😃

Existing Issue Check

File-Type Scope Acknowledgment

sindresorhus commented 3 weeks ago

Maybe we could add a isAnimatedImage property in addition to ext and mime. That could be useful for GIF too.

styfle commented 3 weeks ago

Yeah that would be great!

In particular, I'm looking to replace is-animated which supports GIF, PNG, WebP, but it would also be great to support AVIF as well.

Borewit commented 3 weeks ago

Maybe handy for some users, but putting that in we move to an unclear scope.

What makes isAnimatedImage a relevant file property in module which detects the file type? Why not add the width and height, or the bitrate for audio files.

styfle commented 2 weeks ago

I see what you mean.

Perhaps additional metadata would be opt-in onl. That way, existing use cases that only need the file type can early exit once that’s determined.