Page 1 of 1

How to get the Display from a new image created with Gmic ?

Posted: Tue Feb 16, 2021 2:34 am
by fransua
Hello
I have created a new image with : pdb.plug_in_gmic_qt
This creates an image with an automatic display
When I check the id of this new image with : pdb.gimp_message(gimp.image_list()) I have got : <gimp.Image '[Sans titre]'> (which is referenced as gimp.image_list()[0] )

When I want to close the image, of course I need at first to close the display.
But I don't find a way to save my previous display !

I have tried
saved_display_id=gimp.Display(gimp.image_list()[0] ) -> script doesn't run

Thanks for the help !

Re: How to get the Display from a new image created with Gmic ?

Posted: Tue Feb 16, 2021 3:17 am
by sallyanne
Have you tried exporting it?

Re: How to get the Display from a new image created with Gmic ?

Posted: Tue Feb 16, 2021 6:27 am
by Issabella
Fransua, I hope this explanation can help you.

Re: How to get the Display from a new image created with Gmic ?

Posted: Tue Feb 16, 2021 8:52 am
by fransua
Issabella wrote:Fransua, I hope this explanation can help you.


Thanks Issabella I have use your trick. Create a new layer and export it.

But still there is something mysterious about manipulating display id ...

Re: How to get the Display from a new image created with Gmic ?

Posted: Tue Feb 16, 2021 10:09 am
by ofnuts
I used this in one of my scripts:
Code:
        for displayID in range(1,image.ID+50):
            display=gimp._id2display(displayID)
            if isinstance(display,gimp.Display):
                #print 'Image: %d; display %d' % (image.ID,displayID)
                break
        if not display:
            raise Exception('Display not found')           
        gimp.delete(display)

However, there is no way to make sure that the display you found really belongs to the image (even if starting at image.ID instead of 0 covers your *ss as long as there is only one display for each image opened before the one you are working with).

Re: How to get the Display from a new image created with Gmic ?

Posted: Tue Feb 16, 2021 10:26 am
by fransua
ofnuts wrote:I used this in one of my scripts:
Code:
        for displayID in range(1,image.ID+50):
            display=gimp._id2display(displayID)
            if isinstance(display,gimp.Display):
                #print 'Image: %d; display %d' % (image.ID,displayID)
                break
        if not display:
            raise Exception('Display not found')           
        gimp.delete(display)

However, there is no way to make sure that the display you found really belongs to the image (even if starting at image.ID instead of 0 covers your *ss as long as there is only one display for each image opened before the one you are working with).