How to Add a Python Plug-in to Gimp 2.10 on MacOS

Toby Liu
2 min readDec 3, 2019

--

Because the steps might be different on different OS (Windows / Linux / MacOS) or Gimp versions (2.6 / 2.8 / 2.10), this article only focus on the following system setup:
1. MacOS Catalina Ver. 10.15
2. Gimp Ver. 2.10.12

1 Check the plug-in folder setting. Go to [Preferences] -> [Folders] -> [Plug-ins]. There are some default folders and new folders could also be added.

Screenshot of preference setting of plug-ins folders in Gimp

2Here is a sample plug-in python code, which shows the message in the message box. Please replace [path to Gimp application] with the actual path to Gimp application, for example, /Applications or /Users/username/Applications

#![path to Gimp application]/GIMP-2.10.app/Contents/MacOS/python
from gimpfu import *
import gimp
def python_message(image, drawable, message):
gimp.message(message)
register(
"python_fu_message",
"Show message",
"Show message",
"Pin-Chou Liu",
"Pin-Chou Liu",
"2019",
"<Image>/Filters/Hello World...",
"",
[
(PF_STRING, "message", "message", "Hello World"),
],
[],
python_message)
main()

3 Copy the sample code above, and save the file into one of the folders in the preference setting, for example, python_hello_world.py. Remember to change the permission of the saved file to be executable, for example, chmod 755 python_hello_world.py.

4 Restart Gimp application, and a new menu item “Hello World…” will exist in [Main Menu] -> [Filters]. The location of the new item could be changed by modifying the line “<Image>/Filters/Hello World…”, in the sample code.
After clicking the new item “Hello World…”, a dialog will be displayed and the message string could be modified here.
Then, press OK button to show the message box.

Finally, more customizations, including the location of the new menu item and the UI controls in the plug-in dialog, could be done by modifying the sample code.
Here are some references on the details of the plug-in settings.

  1. https://www.gimp.org/docs/python/index.html
  2. http://sappersblog.blogspot.com/2017/06/writing-gimp-python-plug-ins.html
  3. https://gimplearn.net/viewtopic.php/How-to-write-Plug-in-for-GIMP-in-Python?p=10844#p10844

--

--

Toby Liu
Toby Liu

Written by Toby Liu

iOS developer, ex machine learning and embedded system firmware engineer.

No responses yet