-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
UnidentifiedImageError opening simple PSD using shapes and masks #8034
Comments
Would it be an easy task for you to attach these variations as well for comparison? |
No problem at all. Here's four variants. ExamplePSDWithBottomLayerMaskRemoved.zip ExamplePSDWithTopMostLayerRemoved.zip |
So, the specification states that
and as far as I can see, the byte counts in the first image become incorrect at the end, or end prematurely. However, your code is only trying to open the image. You are not trying to access the PSD layers. I have created #8039 to delay parsing the layers until the user needs Pillow to do so, and with that, your image can be opened successfully - you just can't extract the layers individually. |
Would that be sufficient to resolve this, or do you think that the image is valid and further investigation should be done into reading the layers? |
Apologies for the delay replying. Thanks for the fix! I'm pretty confident this image is valid, as I can open photoshop and create a similar image using the same layer format easily and get the same error. However I can easily fix these images by hand so any further fix is not urgently required. |
If we were to figure out the error, then the 'blue 1' layer would be readable. However, the 'blue' layer would still not be, as Pillow doesn't currently support reading layers with user supplied masks. If you're interested in accessing that as well, then this is a feature request - that doesn't change anything really, just letting you know it may be more difficult than you expected. |
I appreciate this is probably quite tricky given the complexity of PSDs and layers. I have done a bit of experimenting and realised that I am able to access the layer information by using a second library Thanks again for your help so far. |
Pillow 10.4.0 has just been released with #8039 |
What did you do?
Attempted to open the supplied psd image with PIL.open() in python.
I didn't actually create this image myself, nor can I figure out what exactly is wrong with it, but I've managed to reduce the cause of the issue down to 2 shape layers, one with a layer mask. Removing either layer fixes the error. Additionally, inserting a new empty layer between the two layers also fixes the error. So it's not critical and I can work around it, but I have a feeling it's a bug in the psd opening logic if it's somehow fixed by adding blank layers.
Image below of the layers:
What did you expect to happen?
No PIL.UnidentifiedImageError when opening the PSD.
What actually happened?
Received a PIL.UnidentifiedImageError when opening the PSD with PIL.open()
What are your OS, Python and Pillow versions?
Image is attached as zip because github doesn't allow psd attachments.
ExamplePSD.psd.zip (29kb)
Code to reproduce (simple open PSD script):
The text was updated successfully, but these errors were encountered: