-
Notifications
You must be signed in to change notification settings - Fork 337
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
Conversation
@@ -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 && |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
I am interested in adding HEIF support as well. What is currently needed to merge this or otherwise add support? |
@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 |
Duplicated. See #315. |
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/