xiaozhuai / imageinfo

Free Palestine🇵🇸🇵🇸🇵🇸Cross platform super fast single header c++ library to get image size and format without loading/decoding. Support avif, bmp, cur, dds, gif, hdr (pic), heic (heif), icns, ico, j2k, jp2, jpeg (jpg), jpx, ktx, png, psd, qoi, tga, tiff (tif), webp ...
MIT License
106 stars 26 forks source link

Add another format stage #7

Closed Mis1eader-dev closed 6 months ago

Mis1eader-dev commented 6 months ago

Currently if the likely_formats is not met, it goes on to search all other formats. Which may not be needed by the application.

We can make it into 3 stages:

  1. likely_formats: Checks those first, which is a hint given by the programmer that this file is very likely to be in that format. Say the user gave a .png file, then the library can start parsing using the png parser.
  2. supported_formats: If likely_formats failed, it starts looking into the supported formats only, instead of looking into the entire map.
  3. Every other format: If all else fails and the boolean argument must_be_one_of_likely_formats is false, then it starts checking against all other formats.

It is also possible to do it in another way, which is we add a single optional format at the top stage, called very_likely_format, which is hinted to the library by the programmer that this format must be checked first, as it is very likely true. Then it can go in likely_formats to look if it wasn't that format.