It is currently Sun Sep 27, 2026 12:20 am


All times are UTC - 5 hours [ DST ]



Post new topic Reply to topic  [ 9 posts ] 
Author Message
 Post subject: gimp selection save
PostPosted: Tue Jun 19, 2018 1:38 am  (#1) 
Offline
GimpChat Member
User avatar

Joined: Jan 20, 2013
Posts: 14835
Location: roma, italy
GIMP Version: 2.10.2
Operating System: Windows
GIMP Experience: Basic Level

List any relevant plug-ins or scripts:
gimp basic function: selection_save

List any ERROR messages you received:
selected area no more fillable after save



Hi.
During my experiments on gimp 2.10 I encountered this behaviour:

- have an image
- perform a selection on it
- call a filter (.py in my case)
- do inside a filter a "save selection"
- the area inside the selection is no more fillable/active

To double-check:
- download the simple test filter
- have an image with a selection
- pass across the image using the bucket fill tool: the area inside the selection is fillable, the area outside is not: correct
- run the filter with the option save=no
- the image stays as before: area inside is fillable
- now run the filter with option save=yes
- now the area inside the selection is no more fillable: ??

Could it be an error? Or is there something I missed?

Thanks.


Attachments:
TestSaveSel.7z [621 Bytes]
Downloaded 79 times

_________________
"Where am I ?"
Share on Facebook Share on Twitter Share on Orkut Share on Digg Share on MySpace Share on Delicious Share on Technorati
Top
 Post subject: Re: gimp selection save
PostPosted: Tue Jun 19, 2018 3:16 am  (#2) 
Offline
Script Coder
User avatar

Joined: Jun 22, 2010
Posts: 1171
Location: Here and there
With the selection saved I get a message in the Error Console:
GIMP Warning
The active layer is not visible.


The documentation for gimp-selection-save says it creates a new channel, so it appears that it leaves the new channel as the active drawable. Therefore you may need to remember which is the active layer before you save the selection and then re-activate it after saving.


Top
 Post subject: Re: gimp selection save
PostPosted: Tue Jun 19, 2018 3:28 am  (#3) 
Offline
GimpChat Member
User avatar

Joined: Jan 20, 2013
Posts: 14835
Location: roma, italy
Thanks a lot for your suggestion, just adding the statement
pdb.gimp_image_set_active_layer (inImage, inLayer)
after the selection_save
solved the problem.

_________________
"Where am I ?"


Top
 Post subject: Re: gimp selection save
PostPosted: Tue Jun 19, 2018 7:05 am  (#4) 
Offline
Script Coder
User avatar

Joined: Oct 25, 2010
Posts: 4812
paynekj wrote:
With the selection saved I get a message in the Error Console:
GIMP Warning
The active layer is not visible.


The documentation for gimp-selection-save says it creates a new channel, so it appears that it leaves the new channel as the active drawable. Therefore you may need to remember which is the active layer before you save the selection and then re-activate it after saving.


And it has been that way for a long time (at least in 2.8...). No need for a script, "Select>Save to channel" has the same effect. This said, in a script, it shouldn't matter, the initial active drawable is passed as a parameter and this is what the script code should be using (instead of fetching the active layer again(*))

(*) also because the script could be called from another, who would want something to be done to a specific layer which isn't the active layer. Script don't act on the active layer, they act on the layer passed as a a parameter, which, when called from the UI, will usually (but not always...) be the active layer.

_________________
Image


Top
 Post subject: Re: gimp selection save
PostPosted: Tue Jun 19, 2018 11:19 pm  (#5) 
Offline
GimpChat Member
User avatar

Joined: Jan 20, 2013
Posts: 14835
Location: roma, italy
If a script is called with a layer having a selection to be processed by the script, and the script needs to "save the selection" (for instance, for restoring it after some operation), then the script is no more callable again with the same source drawable/selection because of the "not visible active layer" situation illustrated above.
What I mean is that the initial situation is not reset unless the additional step suggested is performed.

_________________
"Where am I ?"


Top
 Post subject: Re: gimp selection save
PostPosted: Tue Jun 19, 2018 11:41 pm  (#6) 
Offline
GimpChat Member
User avatar

Joined: Jan 20, 2013
Posts: 14835
Location: roma, italy
BTW testing the small script posted here at #1 on a gimp 2.8 what I was complaining about does not occur, the source image is always in its initial state, even after the "save selection" step, i.e. the selected area remains fillable; hence something seems to have changed in 2.10.
Can this be double-checked? Thanks.

_________________
"Where am I ?"


Top
 Post subject: Re: gimp selection save
PostPosted: Wed Jun 20, 2018 1:41 am  (#7) 
Offline
Script Coder
User avatar

Joined: Oct 25, 2010
Posts: 4812
This simplified version:
#!/usr/bin/env python
from gimpfu import *

def TestSaveSel210(inImage, inLayer) :

    pdb.gimp_context_push()
    pdb.gimp_selection_save(inImage)
    pdb.gimp_message('Selection saved')
    pdb.gimp_context_pop()
    return
   

register(
    "TestSaveSel210","TestSaveSel210","TestSaveSel210.",
    "Diego","Diego","2018",
    "TestSaveSel210","*",
    [
      (PF_IMAGE, "image", "Input image", None),
      (PF_DRAWABLE, "idrawable", "Input drawable", None),
    ],
    [],
    TestSaveSel210,
    menu="<Image>/Test",
    )

main()

Has the same problem in 2.8. But there is a PDB function to set the active layer, to you can always restore the active layer at the end of your script.

PS: if you con't put parentheses after "gimp_context_push", it does nothing (with is all the better since there is no matching pop()...

_________________
Image


Top
 Post subject: Re: gimp selection save
PostPosted: Wed Jun 20, 2018 4:09 am  (#8) 
Offline
GimpChat Member
User avatar

Joined: Jan 20, 2013
Posts: 14835
Location: roma, italy
Thanks for the double-checking, Ofnuts.
But also using your simplified filter, in my 2.8.22 the input selection area remains fillable (no problem as in 2.10.2 here).

_________________
"Where am I ?"


Top
 Post subject: Re: gimp selection save
PostPosted: Wed Jun 20, 2018 4:30 am  (#9) 
Offline
GimpChat Member
User avatar

Joined: Jan 20, 2013
Posts: 14835
Location: roma, italy
...but today also on 2.10.2 my testing filter works (?!)

phantom effect….

_________________
"Where am I ?"


Top
Post new topic Reply to topic  [ 9 posts ] 

All times are UTC - 5 hours [ DST ]



* Login  



Powered by phpBB3 © phpBB Group