We can do
saved_selection = Gimp.Selection.save(image)
to save a selection.
How can we retrieve that selection later ? Aka load selection from channel?
We can do
saved_selection = Gimp.Selection.save(image)
to save a selection.
How can we retrieve that selection later ? Aka load selection from channel?
When you call:
saved_selection = Gimp.Selection.save(image)
GIMP stores the selection as a channel.
To restore it later, use:
Gimp.Selection.load(saved_selection)
If you need to retrieve it from the image’s channels list (for example after reopening the image), you can access it via:
for channel in image.get_channels():
if channel.get_name() == "Selection Mask":
Gimp.Selection.load(channel)
break
Just make sure you’re loading the correct channel object associated with the saved selection.
And doing this tells me:
Gimp.Selection.load(saved_selection)
^^^^^^^^^^^^^^^^^^^
AttributeError: type object ‘Selection’ has no attribute ‘load’
So, please dear devs tell me how to do it right.
Try:
Gimp.Image.select_item(image, Gimp.ChannelOps.REPLACE, saved_selection)
or
image.select_item(Gimp.ChannelOps.REPLACE, saved_selection)