Repository navigation
fix(psd): skip empty layers when reading PSD files - #5562
Conversation
Allow empty dimensions only for layer records, preserving canvas and decoded channel validation and all upper size limits. Assisted-by: Codex / model identifier unavailable Signed-off-by: jeevan6996 <jeevanpawar5890@gmail.com>
Verify hidden empty layers retain subimage ordering and hashes, with a populated hidden-layer control. Assisted-by: Codex / model identifier unavailable Signed-off-by: jeevan6996 <jeevanpawar5890@gmail.com>
c829a3b to
f586041
Compare
|
I think the most important thing that needs to happen here before finalizing the implementation is to decide what is the right behavior for empty layers: to gracefully allow PSD subimages with 0x0 images (presumably holding metadata only?), or whether to just "skip them" and not report their being in the file. I honestly don't have a preference myself, and am hoping that people who deal with psd files regularly will give us some guidance. Since OIIO doesn't currently output PSD files, we don't have to worry about situations like If we do read them fully, we should implement the |
|
I strongly encourage everybody to write your own PR messages using your actual brains. It's the best proof that you understand what you are submitting. At the very least, even if the robot writes the first draft, please edit it yourself to make it seem like a human thought about it and understood it. That means not including information that is obvious, irrelevant, or that is too specific your personal computer. Since we won't merge a PR without fully passing CI (all tests, all platforms), most of the this information does not need to be stated in the PR description:
All the important information in this entire part could have been stated as: "I checked that the images from the issue failed before and read correctly with this patch, and also that the composite pixel hashes exactly match the previously working release for images without empty layers." |
Signed-off-by: jeevan6996 <jeevanpawar5890@gmail.com>
1f4a4f6 to
c13d2e0
Compare
Keep resolution validation strict and enforce layer size limits while tolerating empty rectangles. Expose only the composite and populated layers, deriving the public count from the resulting image specs. Bound empty channel payloads before seeking past RLE or ZIP data. Preserve independent layer-mask decoding and populated-layer ordering. Assisted-by: Codex / model identifier unavailable Signed-off-by: jeevan6996 <jeevanpawar5890@gmail.com>
Replace runtime generation with fixed PSD/PSB inputs and retain the generator for maintenance. Include RLE row-length tables so compressed empty channels exercise the real parsing path. Check subimage counts, layer order and pixel hashes in normal and raw modes. Cover hidden and trailing empty layers, masks, ZIP payloads, size limits and oversized declared channel lengths. Assisted-by: Codex / model identifier unavailable Signed-off-by: jeevan6996 <jeevanpawar5890@gmail.com>
|
@jessey-git Is this ok and helpful to you as it stands? |
|
Yes, as it stands it fixes the issue on the 3 reported files for us. |
|
@jeevan6996 Before I merge, would you mind please editing the PR description to reflect the final state of the patch and what it does? It doesn't need to describe its history, like "the published patch [does thing it no longer does], then after revision [thing it now does]," and it doesn't need language that appears to be describing your personal machine or the state of the patch while it was still in development, like "the local copy..." or "tests pass locally." And also please add our required AI tool attribution. It's obvious that an LLM was used, but there was no notice. |
Failed run (https://github.com/jeevan6996/OpenImageIO/actions/runs/39145910314). Nanobind change (wjakob/nanobind@a1c8924). |
This is obviously written by a machine. Here's how I would have composed this comment: "The 'bleeding edge' CI test is failing because of a recent change upstream in nanobind. It's unrelated to this PR." |
lgritz
left a comment
There was a problem hiding this comment.
LGTM! Thanks for this fix, and for going through a few iterations to get it just right.
1694550
into
AcademySoftwareFoundation:main
Fixes #5561.
Description
PSD files containing empty layers could fail to open. This change skips layers with zero width or height while preserving the composite image and the order of populated layers. Canvas validation and PSD/PSB dimension limits remain enforced.
Tests
Added checked-in PSD/PSB regression fixtures covering empty layers, subimage ordering and pixel hashes, compressed channels, layer masks, and invalid inputs. The fixture-generation script is retained for reference and maintenance.
The reporter confirmed that the patch fixes all three reported files. (#5562 (comment))
Assisted-by: Codex / GPT-6-Astra