Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Seek past the data when skipping a PSD layer #7483

Merged
merged 1 commit into from Dec 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Binary file added Tests/images/five_channels.psd
Binary file not shown.
5 changes: 5 additions & 0 deletions Tests/test_file_psd.py
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions src/PIL/PsdImagePlugin.py
Expand Up @@ -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:
Expand Down