Skip to content

Conversation

styfle
Copy link

@styfle styfle commented Aug 11, 2025

Add a new exported function imageFormat() that accepts Uint8Array and returns the image format (jpeg/png/etc).

This is basically exposing the existing detector() function and making it compatible with the disabledTypes feature.

if (ext === 'avif' || ext === 'heic') {
// TODO: should we add more granual heif types?
ext = 'heif'
}
Copy link
Author

@styfle styfle Aug 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@netroy Curious about your thoughts on these TODOs here? I think it would be great if we could tell the difference between AVIF and HEIC for example since browsers support AVIF.

Copy link

@netroy
Copy link
Member

netroy commented Aug 11, 2025

If detecting image type is all one needs, why not use image-type instead https://www.npmjs.com/package/image-type ?

@styfle
Copy link
Author

styfle commented Aug 12, 2025

  • image-type is significantly larger because it detects more than just image types (or rather, it depends on file-type)
  • image-type has different logic so there could be a mismatch where we detect the type but not the size
  • last I checked, image-type was slower but I haven't benchmarked recently

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants