GithubHelp home page GithubHelp logo

Comments (8)

radarhere avatar radarhere commented on September 24, 2024

Removing either layer fixes the error. Additionally, inserting a new empty layer between the two layers also fixes the error.

Would it be an easy task for you to attach these variations as well for comparison?

from pillow.

ppearsonhutch avatar ppearsonhutch commented on September 24, 2024

No problem at all. Here's four variants.
I've included in each zip a screen clipping of what the layers look like in photoshop.
All the following .psd files open successfully with PIL.

ExamplePSDWithBottomLayerMaskRemoved.zip

ExamplePSDWithTopMostLayerRemoved.zip

ExamplePSDWithEmptyLayerAdded.zip

ExamplePSDWithBottomLayerRemoved.zip

from pillow.

radarhere avatar radarhere commented on September 24, 2024

So, the specification states that

If the compression code is 1, the image data starts with the byte counts for all the scan lines in the channel (LayerBottom-LayerTop)

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.

from pillow.

radarhere avatar radarhere commented on September 24, 2024

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?

from pillow.

ppearsonhutch avatar ppearsonhutch commented on September 24, 2024

Apologies for the delay replying. Thanks for the fix!
I do actually intend to access the layers later in my use case, so I'm not sure this fix is sufficient for my usage.

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.

from pillow.

radarhere avatar radarhere commented on September 24, 2024

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.

from pillow.

ppearsonhutch avatar ppearsonhutch commented on September 24, 2024

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 psd_tools which means the fix you've implemented so far does resolve the issue I was encountering. I can simply use Pillow to do the image conversion and psd_tools to access the layer information.

Thanks again for your help so far.

from pillow.

radarhere avatar radarhere commented on September 24, 2024

Pillow 10.4.0 has just been released with #8039

from pillow.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.