Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Python-Fu Gimp 3.2.4. Get the active image
#1
Hi!

Question about Python-Fu Gimp 3.2.4

How do I get the active image (the one with focus) from all open images?
Reply
#2
(07-21-2026, 12:56 PM)Burcador Wrote: Hi!

Question about Python-Fu Gimp 3.2.4

How do I get the active image (the one with focus) from all open images?

Its automatically included into the main function arguments by the initial procedure. In this function:
Code:
def my_function(procedure, run_mode, image, drawables, config, data) :

"image" is the active image when you call the plugin.
Reply
#3
(07-21-2026, 03:06 PM)Scallact Wrote: def my_function(procedure, run_mode, image, drawables, config, data) :[/code]

"image" is the active image when you call the plugin.

No, not when the plugin is initialized.

My plugin launches a panel with buttons for launching several plugins.

While it's running, several images are open.
I'm switching between them.
The panel is open.

But how do I determine the active image so I can apply the plugin launched by the panel button to it?

The plugin only detects the active image upon startup. What about during operation?
Reply
#4
(07-21-2026, 03:51 PM)Burcador Wrote: ....snip,,,,
My plugin launches a panel with buttons for launching several plugins.

That reads like this plugin https://www.chuckhenrich.com/custom-command-panel-gimp/

It is up to the user to choose the alternative image, which then brings up the plugin dialog.

   

Maybe have a look at the code, there might be something in it that you can apply to your project.
Reply
#5
(07-21-2026, 04:57 PM)rich2005 Wrote: That reads like this plugin https://www.chuckhenrich.com/custom-command-panel-gimp/
It is up to the user to choose the alternative image, which then brings up the plugin dialog.

The plugin is excellent, thank you.
I'll use it.

However, the author also couldn't find a way to automatically detect the active image.
Instead, he suggests choosing from among the open ones to apply the plugin to, which you launch if you have multiple images.

Basically, I did it in a similar way, except I select the image before launching it.
. . .
But I'd like to find a more elegant way.
Reply
#6
There were feature request about that:

https://gitlab.gnome.org/GNOME/gimp/-/work_items/16502
https://gitlab.gnome.org/GNOME/gimp/-/work_items/6572

so I guess it's not possible yet?
Reply
#7
(07-22-2026, 08:25 AM)MrsP-from-C Wrote: There were feature request about that:
https://gitlab.gnome.org/GNOME/gimp/-/work_items/16502
https://gitlab.gnome.org/GNOME/gimp/-/work_items/6572
so I guess it's not possible yet?

That seems to be the case.
All we can do is wait.
Reply
#8
Honestly, I thought we had an PDB call for this as well.

This merge request may be of interest: https://gitlab.gnome.org/GNOME/gimp/-/me...uests/2923

If merged, getting the active image would be Gimp.context_get_image () in Python.
Reply
#9
(Yesterday, 03:04 AM)CmykStudent_ Wrote: Honestly, I thought we had an PDB call for this as well.

This merge request may be of interest: https://gitlab.gnome.org/GNOME/gimp/-/me...uests/2923

If merged, getting the active image would be Gimp.context_get_image () in Python.

I think there never was. I remember I struggled to get the active image in the python terminal in GIMP 2.10.
Reply
#10
Scallact: Yeah, that seems to be the case. It was just surprising!

At any rate, the code's now merged, so after the next release people can use Gimp.context_get_image () and Gimp.context_set_image () as they like. Thanks everyone here for bringing it up!
Reply


Forum Jump: