Skip to content

Conversation

@radarhere
Copy link
Member

Resolves #7482

When reading through layers in a PSD, Pillow skips layers that have more than 4 channels.

# image info
mode = []
ct_types = i16(read(2))
types = list(range(ct_types))
if len(types) > 4:
continue
for _ in types:
type = i16(read(2))

However, when doing so, there is only a continue. It ignores the fact that there is still data in this file relating to the current layer, that we would have started reading otherwise.

This PR skips past the rest of the layer. I created a test image in GIMP, using a layer mask as the fifth channel for a layer, and then adding another layer after that.

@hugovk hugovk merged commit 7e30619 into python-pillow:main Dec 21, 2023
@radarhere radarhere deleted the psd branch December 21, 2023 10:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Photoshop PSD errors with Truncated File Read

2 participants