GIMP 3.0 is almost out, and I'm thrilled. Not only will this version bring new
features and improvements, but it finally modernizes the technology stack in two important ways:
-
It will use GTK 3
-
It will use Python 3
This will make it easier and more sustainable to develop plugins for GIMP. The
old Python 2 plugins will not work anymore, but the new Python 3 plugins will
be more future-proof. I have a few ideas for plugins I want to write, so the
end of last year I started to dig into it. And while I'm far from the only one
with this idea, information on writing GIMP 3 plugins is naturally still sparse.
So I decided to write down some collected resources and notes. If you have more
resources or tips, feel free to contact me, I'll happily update the article.
-
Plugins can be written in C, Python 3, Scheme, JavaScript and Vala. I will
focus on Python 3.
-
As with GIMP 2.10, GIMP 3.0 ships with a Python interpreter embedded and will not use the system Python.
-
It currently ships Python 3.11
-
The C-API documentation is available at https://developer.gimp.org/api/3.0/
-
The Python API documentation is not yet available to read online, but can be
found in a tarball in on the download page:
https://download.gimp.org/pub/gimp/v3.0/api-docs/ It is however of limited
benefit, since it doesn't contain any information not in the C-API
documentation, except for the exact Python-method names, that can be guessed
easily form the names for their C counterparts.
-
A basic tutorial on how to write a plugin in Python 3 can be found at
https://testing.docs.gimp.org/3.0/en/gimp-using-python-plug-in-tutorial.html
-
Your plugin should be placed in a subfolder of
~/.config/GIMP/3.0/plug-ins/
and the main file must be named the same as the subfolder.
-
GIMP contains a Python REPL that can be started with
Filters -> Development -> Python-Fu -> Console or quicker with the search feature (/ and then type Python)
-
The Python REPL has some code limited completion that sadly only works for classes not for instances.
-
You don't need to restart GIMP, when you edit your plugin. It's loaded from disk on every run.
-
Run GIMP from terminal to see errors and stdout output of your plugin.
-
The GIMP source code repository contains several plugins that can be used as
examples. They are located in the plug-ins folder.
-
If you want to use any Python modules, other than the standard library, you
have to bundle them with your plugin. You can install them in the plugin
folder with
pip install --target /path/to/plugin somepackage
. You
can use the site
module to add additional paths to the Python search path.
-
If you got stuck, you can ask for help on the IRC channel
#gimp-dev
on
irc.gimp.org
.
en gimp