patrickmccallum / mimetype-io

The code for mimetype.io
https://mimetype.io
MIT License
52 stars 12 forks source link

[ADD] image/heif-sequence #20

Open lobau opened 8 months ago

lobau commented 8 months ago

Live Stickers made on iPhone use the .heics file format, which is detected as image/heic-sequence by tools like the file command on Linux, or as accept parameter in an HTML input file (<input type="file" accept="image/heic-sequence" />)

Currently, mimetype.io sends you to a 404 when uploading a .heics file.

Edit: the file command shows image/heif-sequence but in html input you have to use image/heic-sequence as a mask for those files.

Attached an example of such live sticker.

felix.zip

luckv commented 8 months ago

I made some tests, and seems that mimetype.io correctly finds the correct mimetype as image/heic-sequence (you can tell from the address bar). Correctly finds the mimetype of a .heic file, I leave here an example.

@patrickmccallum may could be added the name of the mimetype to the default 404 page, with a link to open an issue with the predefined template? I don't know if it's possible or if it's a big work, just asking.

sample1.zip - The zip contains a file sample1.heic, GitHub don't let me upload .heic files directly

Also these related (not alternative) mimetypes are missing: image/heif-sequence, image/avif. I don't know how these mimetypes are related, and if they are alternatives to one another. @lobau could you give more information about these mimetypes? If you have the time to do that, obviously.

lobau commented 8 months ago

On Firefox 121.0 (Linux), the mimetype is returned correctly for your attached sample .heif, but for any .heics file I try, I get the 404 page.

For your information, .heics files are created with the "live sticker" feature on iOS see https://www.cnet.com/tech/mobile/ios-17-lets-you-turn-your-favorite-pictures-into-live-stickers/

I attached 2 more live stickers, dragged out of the Message app on macOS.

more heics.zip

luckv commented 8 months ago

On Firefox 121.0 (Linux), the mimetype is returned correctly for your attached sample .heif, but for any .heics file I try, I get the 404 page.

Exactly, as I said here:

I made some tests, and seems that mimetype.io correctly finds the correct mimetype as image/heic-sequence (you can tell from the address bar). Correctly finds the mimetype of a .heic file, I leave here an example.

I understand that .heics files display a 404 page, but .heic files do not. Because these files have different mimetypes (image/heic,image/heic-sequence,image/heif,image/heif-sequence), but similar extensions, we need more sources to categorize these mimetypes (their relations, if they represent the same media type) and explain them in mimetype.io.

@lobau Can you provide more official sources, like RFCs, MDN Web docs, or IANA pages, to help us? We cannot publish a mimetype simply because someone tells us 'this is the correct mimetype', even if some command-line tools and browsers agree on this, I hope you understand.

lobau commented 8 months ago

Oh, I have no idea if it's the correct mimetype. I'm building a web app and I'm trying to reliably filter specifically for .heics files. I couldn't find a lot of information online, but I discovered your website while searching for a mimetype sniffer. Your 404 page says to file a bug if it fails to detect the mimetype, which is what I did 😅 I did a quick search around (tried with the file command) but it seems like a very obscure format. I ended up falling back to checking the extension as I can't filter reliably on the mimetype in all browsers. I'll try to look around more, but don't take my word for it!

luckv commented 8 months ago

Ok, I understand the confusion, I don't make it your fault. I don't want a big standard RFC that tells us 'this is the truth'. But there for sure sources online that are trusthworty, some reputable article, some link to MDN web docs, anything linkable that has a reputation. Or maybe you will not find anything of that type. This is may be the case.

Even if you will not find anything reputable (if not official), we can categorize a mimetype as 'chosen as a convention by its large use or from big influence of some organization', to help the people who find mimetype.io understand how a mimetype is used and how standard it is. @patrickmccallum what do you think of this, can it work for you?

I'll try to look around more, but don't take my word for it!

So please, do a little bit of more searching, and if you don't find anything, I will believe you. Open source is built also on volunteer work and trust. For example you can search:

luckv commented 7 months ago

@lobau found something? Anything is good!

luckv commented 7 months ago

@patrickmccallum I made some research, and I figured out that HEIC and HEIF are different mimetypes with different meanings, that heif-sequence and heic-sequence are treated the same by browsers as their respective 'simpler' mimetype (heif and heic). I think that should be added an AVIF section for image/avif mimetype in mimetype.io., I see avif is already present.

In conclusion, @lobau was right, we should handle image/heic-sequence mimetype as assimilitated to image/heic. The file command isn't wrong, because image/heif-sequence is the more general mimetype for .heics files.

I leave all informations that I collected here below. Give them a read if you have time.

HEIF

HEIF is a general format for storing images and image sequences. The images contained can be in any codec.

HEIF features: see wikipedia. A short list includes: store of individual images and thumbnails, store additional data like editing instructions, alpha plane, depth map, exif, xmp.

HEIF files use .heif (image/heif) and .heifs (image/heif-sequence).

Specializations of HEIF

HEIC, AVIF and AVCI are specializations of HEIF where the codec used for the contained images is only one (HEVC for .heic files, AV1 for .avif files and AVC in .avci files)

HEIC is a format developed from Apple. Mimetypes image/heic and image/heic-sequence are the same thing, according to IANA.

AVIF is a specialized format of heif that is open-source, royalty-free, so it's used in web browsers. It was developed by AOMedia. AVIF is also based on MIAF. MIAF is subset of HEIF, with the goal to simplify the implementation for decoders/encoders.

None of mimetypes has a magic number that identify exactly the mimetype when inspecting the file.

File extensions and mimetypes:

Conclusions

HEIF is a general format for images, not fully supported because because it can accept any codec. The 'sequence' variant of the format is threated almost the same by the browsers, but their are not the same, according to AOMedia.

Around the web, many people take the wrong assumption that HEIC is the same as HEIF, but this is absolutely not true.

HEIC and AVIF are the specialized version of HEIF wich use different codecs. They have their own extensions and mimetypes. The 'sequence' variant of the HEIC format is threated almost the same by the browsers, but their are not the same, just like HEIF.

In mimetype.io there should be different sections for heic and avif files, and they should be linked as related to the heic format. The 'sequence' version of each mimetype should be merged in the 'still image' section.

Resources

IANA

Heic (with the general definition of heif): https://www.iana.org/assignments/media-types/image/heic Avif: https://www.iana.org/assignments/media-types/image/avif

Mimetypes image/heif and image/heif-sequence are the same thing, according to IANA. Compare the definition in https://www.iana.org/assignments/media-types/image/heif-sequence

Mimetypes image/heic and image/heic-sequence are the same thing, according to IANA. Compare the definition in https://www.iana.org/assignments/media-types/image/heic-sequence

AOMedia

https://aomediacodec.github.io/av1-avif/

Github discussion on the difference between the still image format ( ex. image/heif) and the sequence format. and because they have different mimetypes (image/heif-sequence): https://github.com/AOMediaCodec/av1-avif/issues/59

MDN

AVIF is the only format included in MDN Web docs: https://developer.mozilla.org/en-US/docs/Web/Media/Formats/Image_types

Wikipedia

https://en.wikipedia.org/wiki/High_Efficiency_Image_File_Format Heif features: https://en.wikipedia.org/wiki/High_Efficiency_Image_File_Format#Features

patrickmccallum commented 6 months ago

Thanks @luckv and @lobau I'll give it all a read and update it.