pytoshop icon indicating copy to clipboard operation
pytoshop copied to clipboard

How to add a layer mask?

Open odieXin opened this issue 3 years ago • 1 comments

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

odieXin avatar Oct 26 '22 04:10 odieXin

set the channels this way:

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

ori-liberman avatar Feb 01 '23 16:02 ori-liberman