GIMP bash, add layer to existing GUI instance

146 Views Asked by At
  1. I'd like to communicate with the existing GUI instance of GIMP, with a plugin. I already have an another app and I want it to add a layer in the current existing GUI instance of GIMP. Is it possible? The scenario is: I open GIMP (GUI), then after some time, my program (in the system) add a layer to my current image I'm working with, without any manual processing in Gimp.

  2. If the first one is not possible, how to make GIMP plugin watch an url with a looping request. I tried with a plugin and it makes my GIMP GUI freeze

1

There are 1 best solutions below

0
On BEST ANSWER

By default there is only one instance of Gimp running, so you can

  1. start Gimp, load one or more images in it
  2. in a bash prompt use something like:
gimp --batch-interpreter python-fu-eval -b "print gimp.image_list()"

Gotchas:

  • the output will appear in Gimp's own stdout. So if you want to see the output of the command above, you have to start Gimp from another terminal, or start it in the background
  • if there are several images loaded, you'll have to find a way to identify the proper image (name, if loaded from file, or it's ID in the title bar)

For more complex code (ie, providing a python file) see this answer, but omit the -b "pdb.gimp_quit(1)" that will make Gimp exit.