-1

I try to write a simple plugin with gimpfu in python and I tried following those instructions.

1.2. Installation Gimp-python consists of a Python module written in C and some native python support modules. You can build pygimp with the commands: ./configure make make install This will build and install gimpmodule and its supporting modules, and install the sample plugins in gimp's plugin directory.

Where do I have to execute those commands?

I tried adding my script to the plugins folder but it seems like there is no python module called gimpfu. I believe I have to enable or install it in some way, but I can't find a solutio to do it.

EDIT: It seems like gimpfu is availible in the gimpfy-console insode gimp. It just doesn't seem to be availible for my plugin scripts.

JaRoMaster
  • 428
  • 1
  • 3
  • 26
  • You'll have to run those commands on the command line of a linux system that can compile c code. – JNevill Sep 14 '22 at 20:55
  • Is there a way to do this on a windows OS? – JaRoMaster Sep 14 '22 at 20:56
  • [See this question](https://stackoverflow.com/questions/32127524/how-to-install-and-use-make-in-windows) I can't imagine it will be very pretty, but it looks possible. – JNevill Sep 14 '22 at 20:58
  • Okay, that might work, but where do I have to execute these commands? And I think by just installing make I wont be able to run ./configure if I am not in the right folder – JaRoMaster Sep 14 '22 at 21:01
  • Also, there is a python-fuoption in my Filters tab - so there seems to be something installed. But pycharm still tells me the plugin doesn't exist and the name I enered in the register function doesn't show up anywhere. I used the following register method: register( "myPlugin", "Test plugin", "Test plugin", "JaRoMaster", "JaRoMaster", "2022", "/Filters/MyPlugin/Test", "RGB*, GRAY*", [], [], print) – JaRoMaster Sep 14 '22 at 21:08

2 Answers2

2

No need to install anything. In the Windows versions Python support is built-in, and the gimpfu import is available when your code is executed by Gimp.

If you don't see the plugin in the menu it is likely a syntax error that doesn't let it run its registration code. See here for some debugging techniques.

However, since you mention PyCharm, you may have another Python interpreter installed and this makes things complicated because there can be conflicts depending on order of installation (and remember, Gimp uses Python 2.7)

Now it all depends if you are really doing a plugin (called from the Gimp menu) or a batch (where Gimp is called from a shell script), which is somewhat different. If you are writing a batch, see this answer for an example.

xenoid
  • 8,396
  • 3
  • 23
  • 49
  • I had Pythoin 3 installed, I just installed Python 2. Do I have to tell Gimp to use python 2 or something like that? I tried to use the example plugin (https://www.gimp.org/docs/python/index.html#EXAMPLE-PLUGIN). I added it to my plugins folder, tried changeing the path in the register function to /Filters/artistic/MyPlugin but in this Tab in gimp the plugin doesn't show up – JaRoMaster Sep 15 '22 at 09:40
  • Besides that, Pycharm gives me the follwing error when trying to import gimpfu: Unresolved reference 'gimpfu'... – JaRoMaster Sep 15 '22 at 09:41
  • When I run GIMP as Admin, I see the plugin. When I import it in the python-fu console, it tells me my Plugon crashed... – JaRoMaster Sep 15 '22 at 09:54
  • As mentioned, you won't see Gimpfu outside of the Gimp environment (unless you manually add it in your Python path/virtial env). Gimpfu is already imported in the Python env used in the console (as `from gimpfu import *`). Also as mentioned having multiple python runtimes can make things very complicated. Also, no need to run Gimp as admin. If you need this, its possibly because the Python path/env is different when you are admin. – xenoid Sep 15 '22 at 10:42
  • Also run Gimp via `gimp-console.exe` to catch any error messages... – xenoid Sep 15 '22 at 10:43
  • Okay, thanks. How do I add gimpfu to my virtual env? – JaRoMaster Sep 15 '22 at 12:02
  • When I try to run gimp console an empty console window opens... No Errors, just nothing happens – JaRoMaster Sep 15 '22 at 12:23
  • If I have an empty .py file in my plugin folder, I get the follwoing Error: LibGimpBase-WARNING: gimp-console-2.10.exe: gimp_wire_read(): error After that, again nothing happns – JaRoMaster Sep 15 '22 at 12:50
  • I see this error message all the time, doesn't prevent my Python code from working. Pu a print statement in your Python file, and check if you see the output in gimp-console. – xenoid Sep 15 '22 at 13:08
1

you don't need to install anything, on windows gimp comes with a python interpreter along with the libraries inside of it.

if you want to run your script from inside GIMP then you should check this answer and you should add the path to gimp to your system PATH environment variable (which is C:\Program Files\GIMP 2\bin on my system) , and instead of calling gimp-console.exe you should replace that with whatever gimp-console is currently available in that folder, the one on my system is gimp-console-2.10.exe.

Ahmed AEK
  • 8,584
  • 2
  • 7
  • 23