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

🐛 Fix export selected layer folder visibility issue #28

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

huchenlei
Copy link

I found this bug when I am developing https://github.com/huchenlei/stable-diffusion-ps-pea.

Steps to reproduce:

  • Set photopea in following state with a folder invisible, and select the folder or anything inside the folder.
    s1
  • Click send to inpaint mask.
    s2
    You can see that the mask is not properly captured.

For comparison, if you select a top level layer and perform the same action:
s3
s4

The issue is caused by original code does not account LayerSet's visibility. For an ArtLayer to be visible on canvas, all it's parent's visibility all need to be true.

By default, add layer to add layer in current LayerSet if the activeLayer is a layerset or add a layer at the same level of the current active layer. So if we select the invisible folder layer, the new temp mask layer is added in the folder.

This PR port my implemenetation of exportSelectedLayerOnly from https://github.com/huchenlei/stable-diffusion-ps-pea, with extra feature of specifying export format and having a callback function to select which layer to export.

}
for (let i = 0; i < allLayers.length; i++) {
const layer = allLayers[i];
const selected = layerSelector ? layerSelector(layer) : layer.selected;
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am checking layer.selected instead for my usecase, as there can be multiple layers selected at the same time. I think for usecase in this repository checking layer.selected is equivalent to check app.activeDocument.activeLayer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant