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

Adding support for heif (i.e. heic files). #298

Closed
wants to merge 4 commits into from

Conversation

jeremysf
Copy link
Contributor

libvips 8.8.0 has added support for .heic files (via libheif). Currently, libheif only supports heic format images. See: strukturag/libheif#83 (comment) for details.

Since iOS 11, this is the Apple iPhone's default image file format making it an important format for software that wants to support uploads of photos take on iPhones.

There are some potential licensing concerns around HEIC/HEIF/HEVC which end users of libvips/bimg need to be aware of, depending on their use case:

https://nokiatech.github.io/heif/
https://www.hevcadvance.com/

@@ -634,6 +642,12 @@ func vipsImageType(buf []byte) ImageType {
if IsTypeSupported(MAGICK) && strings.HasSuffix(readImageType(buf), "MagickBuffer") {
return MAGICK
}
// NOTE: libheif current;y only supports heic sub types; see:
// https://github.com/strukturag/libheif/issues/83#issuecomment-421427091
if IsTypeSupported(HEIF) && buf[4] == 0x66 && buf[5] == 0x74 && buf[6] == 0x79 && buf[7] == 0x70 &&

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried this byte sequence check in Java as below:

return data != null && data.length > 12 && (data[4] == 0x66) && (data[5] == 0x74) && (data[6] == 0x79) && (data[7] == 0x70) && (data[8] == 0x68) && (data[9] == 0x65) && (data[10] == 0x69) && (data[11] == 0x63);

But it doesn't work for sample images at: https://github.com/nokiatech/heif_conformance/tree/master/conformance_files

Do I miss anything @jeremysf ?
Thanks.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I need to update the check I wrote to support more HEIC subtypes. libheif itself doesn't support everything the HEIC container can. I think the right move here is to look at what magic / detection libheif supports and mirror that. I'll update my pull request with that when I get some time or let me know if you get it to first and what you find.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I need to update the check I wrote to support more HEIC subtypes. libheif itself doesn't support everything the HEIC container can. I think the right move here is to look at what magic / detection libheif supports and mirror that. I'll update my pull request with that when I get some time or let me know if you get it to first and what you find.

I've found a checking method which just works for me here:
http://androidxref.com/9.0.0_r3/xref/frameworks/base/media/java/android/media/ExifInterface.java#isHeifFormat

@vansante
Copy link
Contributor

vansante commented Dec 4, 2019

I am interested in adding HEIF support as well. What is currently needed to merge this or otherwise add support?

@vansante
Copy link
Contributor

@jeremysf I have been testing with your branch, and it seems to work fine for .heic files, but not for .heif files.

I have a test file attached here that I can thumbnail with the vipsthumbnail utility just fine, but when attempting to thumbnail it with libvips it claims the file is unsupported:

crowd_1440x960.zip

@h2non
Copy link
Owner

h2non commented Feb 7, 2020

Duplicated. See #315.

@h2non h2non closed this Feb 7, 2020
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.

4 participants