Reputation: 878
I want to convert custom channels into selection using python-fu. This can be done manually in Gimp using "Channel to Selection".
I can retrieve the image and the channel as Python objects but I can’t figure out how to convert this channel to selection.
images = gimp.image_list()
image = images[0]
ch = image.channels[0]
# ?
What I’m missing here is how do a selection from a channel.
Upvotes: 3
Views: 691
Reputation: 878
After some digging, I finally found the answer:
images = gimp.image_list()
image = images[0]
ch = image.channels[0]
pdb.gimp_image_select_item(image, 2, ch)
More info about the second argument in the gimp-image-select-item
documentation I quote here:
The desired operation with current selection { CHANNEL-OP-ADD (0), CHANNEL-OP-SUBTRACT (1), CHANNEL-OP-REPLACE (2), CHANNEL-OP-INTERSECT (3) }
I have the impression the official Python module miss a gimp.Image.select_item(item, operation
method. In my case it would give:
image.select_item(ch, 'replace')
Upvotes: 4