cdgriffith / puremagic

Pure python implementation of identifying files based off their magic numbers
MIT License
158 stars 34 forks source link

JPEG XS Two mime types #52

Closed NebularNerd closed 4 months ago

NebularNerd commented 6 months ago

I was having a look around the various JPEG X* flavours and came across https://en.wikipedia.org/wiki/JPEG_XS which is both a still image and video codec.

Just to be awkward they use the same fingerprint 0xFF10 FF50 for both image and video but then give it two mime types image/jxsc and video/jxsv.

What would be the best approach to handle this? Two entries in the .json one for each type? I'm not sure of other formats that would do this but I reckon they are out there.

cdgriffith commented 6 months ago

There might be more information inside the file itself, I sadly don't have an ISO memebership so can't check the full spec file.

I would personally default to just the image. As even most viewers for JPEG XL / AVIF / HEIF only support the still image aspect of them.

NebularNerd commented 6 months ago

I'll try and find some test files and see if there is an additional fingerprint we could use. Hopefully there will be a nice little byte or two that gives away what inside. 🙂

NebularNerd commented 6 months ago

Mmmm.... Looking at a .jxs image (after compiling the reference software) it seems the images at least have a fairly long fingerprint with a few changes depending on the profile used, then at byte 102 we get 0x49 53 4F 2D 32 31 31 32 32 2D 35 2D 32 2E 30 2E 32 2D 45 44 32 which is ISO-21122-5-2.0.2-ED2

I imagine that would possibly change as drafts are finalised and such, however, the ISO-21122 should remain fixed as it's the designation for the JPEG XS Standard.

EDIT: Get weirder, while .jxs is an image format, it's not the image format that matches the fingerprint. https://www.loc.gov/preservation/digital/formats/fdd/fdd000545.shtml?loclr=blogsig

cdgriffith commented 4 months ago

Added in 1.22 https://github.com/cdgriffith/puremagic/releases/tag/1.22