fdintino / pillow-avif-plugin

A pillow plugin that adds avif support via libavif
BSD 2-Clause "Simplified" License
90 stars 13 forks source link

Accept file signature b"ftypmif1" #5

Closed cosine0 closed 2 years ago

cosine0 commented 3 years ago

Some files use b"ftypmif1" as signatures. But they are not accepted by the _accept function. Please add this to the signature list.

fdintino commented 2 years ago

I believe that is a signature used by HEIF images. Could you provide an example AVIF image with that brand in the ftyp box?

cosine0 commented 2 years ago

According to the AVIF specification draft, HEIF is a container and AVIF is a HEIF file that contains image data. AVIF can be specified by using b'avif' either as the major brand at byte 8-11 following b'ftyp' or as one of the compatible brands starting from byte 16, using b'mif1' as the major brand.

One example using b'mif1' as the major brand is AVIF sample image set provided by Netflix. Relatively new files seem using b'avif'.

I think we need to check additionally for compatible brands to safely accept b'mif1'-AVIF files.

fdintino commented 2 years ago

Those netflix images don't appear to be valid...aomdec and avifdec both give parsing errors. Still, I can accept a broader range of major brands and let the libavif decoder raise the appropriate error if it's not a valid AVIF file. Pillow will fail over to other decoders if they're available so we don't need to worry about trumping another plugin (one for HEIC, for instance).