diff --git a/Tests/images/five_channels.psd b/Tests/images/five_channels.psd new file mode 100644 index 00000000000..021a5fa633b Binary files /dev/null and b/Tests/images/five_channels.psd differ diff --git a/Tests/test_file_psd.py b/Tests/test_file_psd.py index e405834b5ca..708212fa682 100644 --- a/Tests/test_file_psd.py +++ b/Tests/test_file_psd.py @@ -111,6 +111,11 @@ def test_rgba(): assert_image_equal_tofile(im, "Tests/images/imagedraw_square.png") +def test_layer_skip(): + with Image.open("Tests/images/five_channels.psd") as im: + assert im.n_frames == 1 + + def test_icc_profile(): with Image.open(test_file) as im: assert "icc_profile" in im.info diff --git a/src/PIL/PsdImagePlugin.py b/src/PIL/PsdImagePlugin.py index 2f019bb8c34..46970da049b 100644 --- a/src/PIL/PsdImagePlugin.py +++ b/src/PIL/PsdImagePlugin.py @@ -186,6 +186,9 @@ def read(size): ct_types = i16(read(2)) types = list(range(ct_types)) if len(types) > 4: + fp.seek(len(types) * 6 + 12, io.SEEK_CUR) + size = i32(read(4)) + fp.seek(size, io.SEEK_CUR) continue for _ in types: