Skip to content

Commit 6e1831c

Browse files
hugovkradarhere
andauthored
Merge pull request #8056 from radarhere/hdr
Co-authored-by: Andrew Murray <[email protected]>
2 parents 2756cd5 + 50d18bf commit 6e1831c

File tree

3 files changed

+9
-0
lines changed

3 files changed

+9
-0
lines changed

Tests/images/ultrahdr.jpg

47.1 KB
Loading

Tests/test_file_mpo.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,11 @@ def test_eoferror() -> None:
226226
im.seek(n_frames - 1)
227227

228228

229+
def test_ultra_hdr() -> None:
230+
with Image.open("Tests/images/ultrahdr.jpg") as im:
231+
assert im.format == "JPEG"
232+
233+
229234
@pytest.mark.parametrize("test_file", test_files)
230235
def test_image_grab(test_file: str) -> None:
231236
with Image.open(test_file) as im:

src/PIL/JpegImagePlugin.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -831,6 +831,10 @@ def jpeg_factory(fp=None, filename=None):
831831
try:
832832
mpheader = im._getmp()
833833
if mpheader[45057] > 1:
834+
for segment, content in im.applist:
835+
if segment == "APP1" and b' hdrgm:Version="' in content:
836+
# Ultra HDR images are not yet supported
837+
return im
834838
# It's actually an MPO
835839
from .MpoImagePlugin import MpoImageFile
836840

0 commit comments

Comments
 (0)