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

Do not detect Ultra HDR images as MPO #8056

Merged
merged 3 commits into from
Jun 26, 2024
Merged

Conversation

radarhere
Copy link
Member

Resolves #8052

The Ultra HDR format stores its gain map as an additional MPO image. However, as the issue has found, because we do not support Ultra HDR images, the additional image appears incorrectly.

Instead, this PR treats such files as standard JPEGs.

https://developer.android.com/media/platform/hdr-image-format#signal_of_the_format details how this format can be detected.

A JPEG file conforming to this format may be identified by the presence of hdrgm:Version="1.0" in the primary image's XMP packet

@hugovk
Copy link
Member

hugovk commented Jun 25, 2024

Tests/images/ultrahdr.jpg is about half a megabyte, not our biggest test image (which is 9.9 MB!), but still pretty big.

Can we find a smaller image to include in the test suite? cc @bigcat88

@bigcat88
Copy link
Contributor

I am not the author of that image.

Here is the link to the message of author #8052 (comment)

where he mentions that he does not have the smaller image (

@radarhere
Copy link
Member Author

@hugovk would you prefer I create a smaller image artificially?

@hugovk
Copy link
Member

hugovk commented Jun 25, 2024

If it's not too difficult and it doesn't feel too hacky? Otherwise the one already here is probably fine. Just keeping an eye on our 46.6 MB sdist.

@radarhere
Copy link
Member Author

I've realised that since we're not loading the image, I can just truncate the file leaving only the data that's read in the initial open. The test image is now down to 48kb.

@hugovk hugovk merged commit 6e1831c into python-pillow:main Jun 26, 2024
55 of 56 checks passed
@radarhere radarhere deleted the hdr branch June 26, 2024 08:41
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.

Is this MPO file decoded correctly?
3 participants