Gimp-Forum.net
How to test if there is a selection. - Printable Version

+- Gimp-Forum.net (https://www.gimp-forum.net)
+-- Forum: GIMP (https://www.gimp-forum.net/Forum-GIMP)
+--- Forum: Extending the GIMP (https://www.gimp-forum.net/Forum-Extending-the-GIMP)
+---- Forum: Scripting questions (https://www.gimp-forum.net/Forum-Scripting-questions)
+---- Thread: How to test if there is a selection. (/Thread-How-to-test-if-there-is-a-selection)



How to test if there is a selection. - david - 10-02-2020

How do I test to find if an image has a selection?
What I wish to do is: If image has selection, then do something.

I'm afraid that I find the descriptions in the Python console as clear as mud! Perhaps they are OK for someone who alreay knows the answer.

david.


RE: How to test if there is a selection. - Kevin - 10-02-2020

I would have thought gimp-selection-is-empty would be the one to use


RE: How to test if there is a selection. - Ofnuts - 10-02-2020

(10-02-2020, 04:07 PM)Kevin Wrote: I would have thought gimp-selection-is-empty would be the one to use

Same here.


RE: How to test if there is a selection. - david - 10-02-2020

Many thanks Kevin.
My problem this time was with the English! gimp_selection_is_empty implied to me that a selection existed, but contained nothing.
gimp_no_selection or gimp_selection_absent would be more self-explanatory!
david.


RE: How to test if there is a selection. - Ofnuts - 10-03-2020

(10-02-2020, 10:55 PM)david Wrote: Many thanks Kevin.
My problem this time was with the English! gimp_selection_is_empty implied to me that a selection existed, but contained nothing.
gimp_no_selection or gimp_selection_absent would be more self-explanatory!
david.

So the call is appropriately named, because technically the selection is always here... image.selection or pdb.gimp_image_get_selection(image) will always return a channel, but you would have to use the histogram calls to determine if there are any non-zero pixels in it.