Comments (8)
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.
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.
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.
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.
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.
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.
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.
Pillow 10.4.0 has just been released with #8039
from pillow.
Related Issues (20)
- `Image.fromqimage()` raises `TypeError` HOT 2
- `alpha_composite` works poorly with transparency
- Windows Docker / nanoserver support HOT 8
- Save GIF without loss of quality HOT 23
- scientific-python-nightly-wheels-publish triggered in fork HOT 1
- `ImageFont` claims to load font sizes in pixels but seems to use points? HOT 6
- Problems HOT 1
- Emf file is not handled correctly HOT 2
- Bitmap missing for glyph HOT 4
- ImportError: cannot import name '_imagingft' from 'PIL' HOT 7
- Cannot install Tkdesigner HOT 2
- Cannot install Tkdesigner HOT 14
- Add XMP writing HOT 7
- Add SVG Support Using PlutoSVG HOT 3
- ImageDraw.rounded_rectangle: wrong ValueError HOT 2
- Crash when using `Draw.text` with invalid type HOT 2
- ImportError: cannot import name 'PILLOW_VERSION' from 'PIL' (python3.7, PILLOW vers < 9.0) HOT 8
- Scale factor for resizing HOT 3
- `ValueError: encoding error 5` during WEBP encoding should be replaced with something more informative HOT 3
- Impossible to detect multi-images tiff pages HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pillow.