Mobile app version of vmapp.org
Login or Join
Frith110

: How to mask a layer from a channel in GIMP with Python? I've been 3 days searching for documentation about python-fu for GIMP 2.8, and the one I find is great, but deprecated. So I'm now

@Frith110

Posted in: #Gimp #Layers #Mask #Python

I've been 3 days searching for documentation about python-fu for GIMP 2.8, and the one I find is great, but deprecated.

So I'm now stuck at this place: I've created 3 color channels, and want to add each one of them as a mask to each of 3 layers.

What I've done till now: (manually load the image, and create 3 color channels for lights, middle tones and shadows);

Get it's ID, with:

ima = gimp.image_list()[0]


Get the layer ID and duplicate the layer 3 times:

layn = pdb.gimp_layer_new_from_visible(ima, ima, 'dup')
pdb.gimp_image_insert_layer(ima, layn, None, -1)


Now I have an image with three layers and want to add a layer mask to each of the 3 layers but from the 3 different color channels... but I don't know how.

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Frith110

1 Comments

Sorted by latest first Latest Oldest Best

 

@Dunderdale640

The API doesn't seem to support creating a mask directly from a random channel. But you can create a mask from the selection, so:


Copy your channel into the selection

pdb.gimp_image_select_item(image,CHANNEL_OP_REPLACE,channel)

Create the mask

mask=layer.create_mask(ADD_SELECTION_MASK)

Add the mask to the layer:

layer.add_mask(mask)

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme