Merge pull request #5408 from radarhere/indexerror

Corrected JPEG APP14 transform value
This commit is contained in:
Hugo van Kemenade 2021-04-25 11:36:40 +03:00 committed by GitHub
commit d3a3b6dddb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 2 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

View File

@ -795,6 +795,20 @@ class TestFileJpeg:
apps_13_lengths = [len(v) for k, v in im.applist if k == "APP13"]
assert [65504, 24] == apps_13_lengths
def test_adobe_transform(self):
with Image.open("Tests/images/pil_sample_rgb.jpg") as im:
assert im.info["adobe_transform"] == 1
with Image.open("Tests/images/pil_sample_cmyk.jpg") as im:
assert im.info["adobe_transform"] == 2
# This image has been manually hexedited
# so that the APP14 reports its length to be 11,
# leaving no room for "adobe_transform"
with Image.open("Tests/images/truncated_app14.jpg") as im:
assert "adobe" in im.info
assert "adobe_transform" not in im.info
def test_icc_after_SOF(self):
with Image.open("Tests/images/icc-after-SOF.jpg") as im:
assert im.info["icc_profile"] == b"profile"

View File

@ -140,8 +140,8 @@ def APP(self, marker):
self.info["adobe"] = i16(s, 5)
# extract Adobe custom properties
try:
adobe_transform = s[1]
except Exception:
adobe_transform = s[11]
except IndexError:
pass
else:
self.info["adobe_transform"] = adobe_transform