Skip to content
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

[Feature request] - Layer Masks #391

Open
ImportTaste opened this issue Mar 1, 2022 · 4 comments
Open

[Feature request] - Layer Masks #391

ImportTaste opened this issue Mar 1, 2022 · 4 comments
Labels
fixed (hopefully)

Comments

@ImportTaste
Copy link

Layer masks are grayscale representations of transparency that are applied to either layers or layer groups. White represents visible, black is completely invisible, and grays are in between.

https://helpx.adobe.com/photoshop/using/masking-layers.html

Worth mentioning in Photoshop I often use layer masks on groups, so if PhotoDemon could somehow take layer masks applied to the 'Group start' layer when exporting (at least until PhotoDemon has real layer groups), that would be appreciated.

@tannerhelland
Copy link
Owner

Hello @ImportTaste . Thank you for filing this issue. It is a great suggestion.

Whenever it's convenient, can you attach a PSD file with a mask attached to a layer group? That would really help me in testing.

Many thanks!

@Kroc
Copy link
Contributor

Kroc commented Mar 2, 2022

These are also part of Paint Shop Pro; in PSP7 the mask is attached directly to each layer. In PSPX (8, 9, maybe?) masks can be used on groups (as @ImportTaste mentions)

@ImportTaste
Copy link
Author

Hello @ImportTaste . Thank you for filing this issue. It is a great suggestion.

Whenever it's convenient, can you attach a PSD file with a mask attached to a layer group? That would really help me in testing.

Many thanks!

Here you go: example.psd.zip

tannerhelland added a commit that referenced this issue Mar 24, 2022
Relates to #391.  Thank you to @ImportTaste for filing the original bug report.

This is the first of several commits aimed at successfully round-tripping layer group masks from PSD files.  In this first commit, PhotoDemon can now successfully retrieve group masks, and if a debug constant is enabled, it'll even load them as the pixel data for the "dummy" layer group layers we create.  (This obviously causes the composite image to display weirdly, but it's very helpful to me so I can see what's happening with a given group.)

My next task is to "tag" group layers with mask data (as an optional add-on) and ensure that data persists for the life of the target group.  The final task will then be to figure out how to export the mask in a PSD-compatible way.
tannerhelland added a commit that referenced this issue Mar 24, 2022
tannerhelland added a commit that referenced this issue Mar 24, 2022
Relates to #391

Masks are not persisted yet, but this at least gives me a way to tag layers with mask data.
tannerhelland added a commit that referenced this issue Mar 29, 2022
tannerhelland added a commit that referenced this issue Mar 30, 2022
Next up: round-tripping that data back out to PSD!

Relates to #391
tannerhelland added a commit that referenced this issue Mar 30, 2022
Relates to #391

PhotoDemon can now read layer group masks from PSD files, cache the masks throughout other edits (including rearranging group markers), then correctly write all group mask(s) back out to PSD later.

I've tested a variety of group masks implemented in various ways, and they all work nicely against Photoshop CS2 (the latest version I have available for testing; external testing help against CC would be most welcome).
@tannerhelland
Copy link
Owner

Hello @ImportTaste . The latest PhotoDemon nightly builds are now able to successfully round-trip layer group masks from PSD files. Your test image was very helpful for getting this project underway - thank you again for sending it.

I have aggressively tested the new PhotoDemon code against many different group masks images coming from Photoshop CS2. I don't expect issues in other PS versions, but if you encounter any unexpected results, please let me know.

Also - group masks will persist through nearly all edits in PhotoDemon (including adjustments, effects, rearranging layers and group markers, etc) - but actions that affect image or layer sizes like Image > Resize will not resize any layer group masks just yet. I will work on adding that level of group mask support in the coming months.

@tannerhelland tannerhelland added fixed (hopefully) and removed in-progress labels Mar 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fixed (hopefully)
Projects
None yet
Development

No branches or pull requests

3 participants