diff --git a/Tests/images/icc-after-SOF.jpg b/Tests/images/icc-after-SOF.jpg new file mode 100644 index 000000000..a284a2298 Binary files /dev/null and b/Tests/images/icc-after-SOF.jpg differ diff --git a/Tests/test_file_jpeg.py b/Tests/test_file_jpeg.py index 9f963d80f..8fc4e121d 100644 --- a/Tests/test_file_jpeg.py +++ b/Tests/test_file_jpeg.py @@ -689,6 +689,10 @@ class TestFileJpeg: apps_13_lengths = [len(v) for k, v in im.applist if k == "APP13"] assert [65504, 24] == apps_13_lengths + def test_icc_after_SOF(self): + with Image.open("Tests/images/icc-after-SOF.jpg") as im: + assert im.info["icc_profile"] == b"profile" + @pytest.mark.skipif(not is_win32(), reason="Windows only") @skip_unless_feature("jpg") diff --git a/src/PIL/JpegImagePlugin.py b/src/PIL/JpegImagePlugin.py index 2aa029efb..0e1a9cc0f 100644 --- a/src/PIL/JpegImagePlugin.py +++ b/src/PIL/JpegImagePlugin.py @@ -221,7 +221,7 @@ def SOF(self, marker): else: icc_profile = None # wrong number of fragments self.info["icc_profile"] = icc_profile - self.icclist = None + self.icclist = [] for i in range(6, len(s), 3): t = s[i : i + 3]