Skip to content

Commit

Permalink
Do not detect Ultra HDR images as MPO
Browse files Browse the repository at this point in the history
  • Loading branch information
radarhere committed May 13, 2024
1 parent e39ee95 commit 631ed34
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
Binary file added Tests/images/ultrahdr.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions Tests/test_file_mpo.py
Expand Up @@ -225,6 +225,10 @@ def test_eoferror() -> None:
# Test that seeking to the last frame does not raise an error
im.seek(n_frames - 1)

def test_ultra_hdr() -> None:
with Image.open("Tests/images/ultrahdr.jpg") as im:
assert im.format == "JPEG"


@pytest.mark.parametrize("test_file", test_files)
def test_image_grab(test_file: str) -> None:
Expand Down
4 changes: 4 additions & 0 deletions src/PIL/JpegImagePlugin.py
Expand Up @@ -843,6 +843,10 @@ def jpeg_factory(fp=None, filename=None):
try:
mpheader = im._getmp()
if mpheader[45057] > 1:
for segment, content in im.applist:
if segment == "APP1" and b' hdrgm:Version="' in content:
# Ultra HDR images are not yet supported
return im
# It's actually an MPO
from .MpoImagePlugin import MpoImageFile

Expand Down

0 comments on commit 631ed34

Please sign in to comment.