bojand / infer

Small crate to infer file and MIME type by checking the magic number signature
MIT License
299 stars 28 forks source link

Add support for heix (iOS 18) #100

Open robbassi opened 4 months ago

robbassi commented 4 months ago

We ran into some issues processing HEIC files from iOS 18 devices. It looks like Apple changed some of the metadata for HEIC files on the latest release.

This what we typically see for a HEIC file:

$ xxd -d -c 16 -l 16 -b test.heic 
[bytes truncated] 01100011 00000000 00000000 00000000 00000000  ....ftypheic....
$ xxd -d -c 16 -l 16 -b sample.heic
[bytes truncated] 00110001 00000000 00000000 00000000 00000000  ....ftypmif1....

But the HEIC images we get from iOS 18 contain the following:

$ xxd -d -c 16 -l 16 -b sample2.heic
[bytes truncated] 01111000 00000000 00000000 00000000 00000000  ....ftypheix....

Testing it with file, we see the mime-type is:

$ file --mime-type sample2.heic 
sample2.heic: image/heic

This PR updates the check for heic to include heix, and adds a new test case + test data.

stephenjudkins commented 4 months ago

Nice work @robbassi! Rob is going to be on vacation for the next month so I can handle any feedback here