strukturag / libheif

libheif is an HEIF and AVIF file format decoder and encoder.
Other
1.6k stars 292 forks source link

Unable to convert heic to jpg taken by iPhone 15 pro iOS18 #1190

Closed tza17313 closed 1 week ago

tza17313 commented 2 weeks ago

I found that the heic format photos taken by iPhone15 pro under iOS18 cannot be converted to jpg by heif-convert

libheif version: 1.17.6

Here are some logs:

nero@d2c24395c402:/upload# heif-convert IMG_1159.HEIC 1.jpg
Could not read HEIF/AVIF file: Invalid input: Unspecified: Too many auxiliary image references

nero@d2c24395c402:/upload# heif-info IMG_1159.HEIC
MIME type: image/heic
main brand: heic
compatible brands: tmap, heic, mif1
Could not read HEIF/AVIF file: Invalid input: Unspecified: Too many auxiliary image references

When the iPhone 15 Pro system is still iOS17, the HEIC photos taken can be converted to JPG using the above command.

The file can be downloaded via the link below:

IMG_1159.zip

https://drive.google.com/file/d/1kEBvALrnM0EUwkQzsg8YL0Pwd8ZpRWWO/view?usp=sharing

bradh commented 2 weeks ago

Can you try with this branch: https://github.com/strukturag/libheif/tree/develop-v1.18.0 ?

I think I have that resolved by https://github.com/strukturag/libheif/commit/58ba30df608e540bfd0f4e5642ba79ba0dfd7628

farindk commented 2 weeks ago

With develop-v1.18.0, I get:

Could not read HEIF/AVIF file: Invalid input: Non-existing item ID referenced: Non-existing aux image referenced

Maybe the problem is that a referenced image is a tmap image.

fxthomas commented 1 week ago

For reference: the tmap image is a derived image (more info about that HEIF feature here) that implements the upcoming ISO/CD 21496-1 standard which is meant to replace all the current incompatible/proprietary HDR gain map implementations.

It sounds like it's ignored by m_all_images in libheif/context.cc because the derived image type is not yet supported, but some other items reference it and make parsing fail.

I used GPAC/mp4box on one of the samples I have and I think at least the EXIF block reference both the primary image and the tmap -- I could be wrong, the structure is difficult to parse (mentally) as I'm not used to it.

farindk commented 1 week ago

Yes, we even have a pull request to add tmap support, but I didn't integrate it yet as nothing about the standard is public yet. Or I didn't find it. Adobe has removed all specific information from their website.

On the other hand, we should probably ignore all references that we cannot parse because there might be other extensions in the future that give rise to the same issue.

farindk commented 1 week ago

Fixes this. Gain map is not read yet.