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

How to add a layer mask? #34

Open
odieXin opened this issue Oct 26, 2022 · 1 comment
Open

How to add a layer mask? #34

odieXin opened this issue Oct 26, 2022 · 1 comment

Comments

@odieXin
Copy link

odieXin commented Oct 26, 2022

What I have tried:

im = Image.open('a.png')
arr = numpy.array(im)
channels = [arr[:,:,0], arr[:,:,1], arr[:,:,2]]
data = ImageData(channels=numpy.array(im))
testLayer = nested_layers.Image(name='image1', visible=True, opacity=255, group_id=0, 
blend_mode=enums.BlendMode.normal, top=0,
left=0, bottom=im.height, right=im.width, channels=channels,
metadata=None, layer_color=0, color_mode=None)
layers = []
layers.append(newLayer)

How can I add a layer mask to this layer? @mdboom

@ori-liberman
Copy link

set the channels this way:

channels={}
channels[-1] = arr[:, :, 3] # alpha channel
channels[0] = arr[:, :, 0]
channels[1] = arr[:, :, 1]
channels[2] = arr[:, :, 2]

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

No branches or pull requests

2 participants