Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add support for the AVIF, HEIC and HEIF formats #13

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

bu6n
Copy link

@bu6n bu6n commented Sep 9, 2024

This PR adds support for the AVIF, HEIC and HEIF formats.

These 3 formats have in common that they use the HEIF container format specified in ISO/IEC 23008-12.

https://nokiatech.github.io/heif/technical.html also summarizes the format quite well.

The MIME types and variant types (file extension) for HEIC and HEIF are based on sections C.2 and D.2 of the ISO specification:

C.2
[...]
C.2

D.2
[...]
D.2

A HEIF container can contain multiple images, so I kept the logic as in :ico (take the size of the largest image).

The size of an image is found in the ispe box:

ispe

Examples here: https://mpeggroup.github.io/FileFormatConformance/?query=%3D%22ispe%22

This is also valid for AVIF per the specification: https://aomediacodec.github.io/av1-avif/latest-approved.html#image-spatial-extents-property

If you find the approach ok, I could add some tests. I have tested it with some images I have found online and compared the results with exiftool, but improvements are probably still possible.

Let me know what you think.

closes #12

@bu6n bu6n force-pushed the heif branch 3 times, most recently from d7b772b to d6a9686 Compare September 9, 2024 09:36
These 3 formats have in common that they use the HEIF container format specified in ISO/IEC 23008-12.

The MIME types and variant types (file extension) for HEIC and HEIF are based on sections C.2 and D.2 of the specification.

A HEIF container can contain multiple images, so the logic is kept as in `:ico` (take the size of the largest image).

The size of an image is found in the `ispe` box.
@rNoz
Copy link
Collaborator

rNoz commented Sep 19, 2024

Thanks for this, @bu6n. Great addition. Yes, it seems a proper approach mimicking the style of the previous ones, so be sure you add enough proper tests and check coverage to be sure ~100% of new code is tested. Checking the code, performance should be close to its optimal, so, I won't worry about doing benchmarks again for these new formats. Nevertheless, if you think about any optimization while doing test coverage, feel free to try and let me know (benchee could help for quick verifications).

@rNoz rNoz self-requested a review September 19, 2024 09:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

HEIF support
2 participants