RSS/Atom feed Twitter
Site is read-only, email is disabled

Get currently active image in python

This discussion is connected to the gimp-developer-list.gnome.org mailing list which is provided by the GIMP developers and not related to gimpusers.com.

This is a read-only list on gimpusers.com so this discussion thread is read-only, too.

5 of 5 messages available
Toggle history

Please log in to manage your subscriptions.

Get currently active image in python Jon Decker 19 Mar 11:39
  Get currently active image in python Chris Mohler 20 Mar 16:03
Get currently active image in python Chris Mohler 23 Mar 18:06
  Get currently active image in python Joao S. O. Bueno 02 Apr 14:06
   Get currently active image in python Jon Decker 03 Apr 09:50
Jon Decker
2012-03-19 11:39:05 UTC (about 12 years ago)

Get currently active image in python

Hello

I've been developing a plugin for my wife for her photography business. I'm using GTK and sqlite successfully in the plugin.

I'm at a part where I need to be able to find out the currently active image (the image that is selected in gimp). I have tried:
activeImage = gimp.image_list()[0]

but this only returns the most recently opened image, and not the currently selected image in gimp. Is there a way to get the currently selected image from gimp from within python?

thanks!

Chris Mohler
2012-03-20 16:03:21 UTC (about 12 years ago)

Get currently active image in python

On Mon, Mar 19, 2012 at 6:39 AM, Jon Decker wrote:

I'm at a part where I need to be able to find out the currently active image (the image that is selected in gimp). I have tried:
activeImage = gimp.image_list()[0]

When you call the plugin's main function, you will automatically have access to the current image and drawable.

So something like this:

def my_plugin_function (image, drawable): print image

Will output the image object if gimp was started from a terminal. This is a bare-bones plugin that adds guides to the current image: http://registry.gimp.org/files/rule_of_thirds_guides.py

HTH, CHris

Chris Mohler
2012-03-23 18:06:51 UTC (about 12 years ago)

Get currently active image in python

On Fri, Mar 23, 2012 at 12:51 PM, Jon Decker wrote:

Thanks for the reply.  I do realize that the current image and drawable is passed to the plugin when first opened.  Perhaps I should explain further. I'm trying to build more of an extension that is opened just once, and updates as you move from image to image. (Its a time tracking window which stays open along side gimp).  I wanted to make it so that a new instance of the plugin doesn't have to run for each image - just open it once, and it "knows" which image is currently active so that it can populate my sqlite database.

Is there a way to do this at in in gimp?

I'm not sure (reposting to list - be sure to 'reply-all' vs just 'reply').

Chris

Joao S. O. Bueno
2012-04-02 14:06:49 UTC (about 12 years ago)

Get currently active image in python

On 23 March 2012 15:06, Chris Mohler wrote:

On Fri, Mar 23, 2012 at 12:51 PM, Jon Decker wrote:

Thanks for the reply.  I do realize that the current image and drawable is passed to the plugin when first opened.  Perhaps I should explain further. I'm trying to build more of an extension that is opened just once, and updates as you move from image to image. (Its a time tracking window which stays open along side gimp).  I wanted to make it so that a new instance of the plugin doesn't have to run for each image - just open it once, and it "knows" which image is currently active so that it can populate my sqlite database.

Is there a way to do this at in in gimp?

No, there is not - at least no clean ways that I can think of. There is nothing on the GIMP's API that marks an image as the currently active image.(The "unclean way" I can think of would mean to use GTK+ instrumentation for GUI debugging to be able to introspect active
windows, and infere the active image from its title)

Another "unclean", but tidier, way would be to create a very simple script, with no parameters but "image and drawable" that would just signal your main plug-in when called - and you could bind it to a shortcut key and press it everytime you switch the active image.

To notify your mainplug-in you could use some file-system signaling mechanism, xmlrpc, or some gtk+ mechanism..

I'd use this second approach.

I'm not sure (reposting to list - be sure to 'reply-all' vs just 'reply').

Chris _______________________________________________ gimp-developer-list mailing list
gimp-developer-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gimp-developer-list

Jon Decker
2012-04-03 09:50:23 UTC (about 12 years ago)

Get currently active image in python

Ok thanks for the information. I think I'll file a feature request as well - I think this would be a great addition to the API

On Mon, Apr 2, 2012 at 10:06 AM, Joao S. O. Bueno wrote:

On 23 March 2012 15:06, Chris Mohler wrote:

On Fri, Mar 23, 2012 at 12:51 PM, Jon Decker

wrote:

Thanks for the reply. I do realize that the current image and drawable

is

passed to the plugin when first opened. Perhaps I should explain

further.

I'm trying to build more of an extension that is opened just once, and updates as you move from image to image. (Its a time tracking window

which

stays open along side gimp). I wanted to make it so that a new

instance of

the plugin doesn't have to run for each image - just open it once, and

it

"knows" which image is currently active so that it can populate my

sqlite

database.

Is there a way to do this at in in gimp?

No, there is not - at least no clean ways that I can think of. There is nothing on the GIMP's API that marks an image as the currently active image.(The "unclean way" I can think of would mean to use GTK+ instrumentation for GUI debugging to be able to introspect active
windows, and infere the active image from its title)

Another "unclean", but tidier, way would be to create a very simple script, with no parameters but "image and drawable" that would just signal your main plug-in when called - and you could bind it to a shortcut key and press it everytime you switch the active image.

To notify your mainplug-in you could use some file-system signaling mechanism, xmlrpc, or some gtk+ mechanism..

I'd use this second approach.

I'm not sure (reposting to list - be sure to 'reply-all' vs just

'reply').

Chris
_______________________________________________ gimp-developer-list mailing list
gimp-developer-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gimp-developer-list