Suppose I want to copy the red channel of an image (thus creating a new channel). How do I do that with Python-Fu?
EDIT: basically, I need to create luminosity masks. So far, I tryed the following code:
# get active layer
layer = pdb.gimp_image_get_active_layer(image)
# copy the selected layer
layer_copy = pdb.gimp_layer_new_from_drawable(layer, image)
# insert the layer_copy on top of the layers stack
pdb.gimp_image_insert_layer(image, layer_copy, None, 0)
# desaturate the layer
pdb.gimp_drawable_desaturate(layer_copy, DESATURATE_LIGHTNESS)
# select the red channel
ch = pdb.gimp_channel_new_from_component(image, 0, "testchannel")
pdb.gimp_image_insert_channel(image, ch, 0, 1)
Unfortunately I got the error TypeError: wrong parameter type
on the last command pdb.gimp_image_insert_channel(image, ch, 0, 1)