Resources for Creating Python-fu Plugins in GIMP  

by Matt Hawkins, 11/01/2013
Categories : Multimedia : Python

GIMP (The GNU Image Manipulation Program) is a graphics and photo editing application for Linux and Windows. It could be compared to Photoshop but unlike the Adobe product is completely free to use. For this reason I use it exclusively for all my image editing requirements. Why pay for or pirate Photoshop when you can legally use GIMP for free? Most the majority of users GIMP can do everything you need.

A great feature of GIMP is the ability to create your own plugins to automate tasks. These plugins can be created in Script-fu or Python-fu. I tried Script-fu last year and it was awful. The documentation was weak, examples were thin on the ground and the syntax makes no sense whatsoever. Whoever you are your time is not worth wasting on Scipt-fu. I'm sure there is a reason Script-fu is like this (i.e. it's based on 'Scheme') but from the perspective of a normal user it is horribly complicated and messy.

Python LogoLuckily GIMP also supports 'Python-fu'. This is based on Python which is much easier to worth with. Details of Python can be found on and there are thousands of tutorials and websites out there to help with it's features, functions and syntax.

As a result I have now managed to create some Python-fu plugins. It isn't all plan sailing so I created this page in an attempt to present some resources I found useful in creating my first plugins.

Online Resources

GIMP Python Documentation
This page outlines the interfaces to GIMP-Python. It provides an example Python-fu GIMP Plugin which can be used as the basis for a new plugin.

Extending Gimp with Python
A great site that provides some Python-fu tutorials. These include how to create a new plugin and good explanations of features only vaguely mentioned in the official documentation.

GIMP Plugin Registry
This is the official repository of plugins for GIMP. Before creating your own it is a useful place to look for plugins with similar functionality. You might be able to find a plugin that you can use as a basis for your own creations.

If you are searching Google for resources including "GIMP" and "python-fu" in your search query should result in some useful results. If you are looking for general Python commands then you can just look for general resources using "python".

Example GIMP Python Plugin

Here is a very simple example Python-fu plugin :

#!/usr/bin/env python

# GIMP Plugin - Hello World
# Copyright (c) 2013 Matt Hawkins

# This is an example Python-fu plugin
# It changes the background and foreground colours to red and green.

from gimpfu import *
def python_hello_world(timg, tdrawable):
  g = gimp.pdb

  # Set foreground and background colours
  # Do other stuff here
  # ...
  # ...

        "It changes the background and foreground colours to red and green.",
        "It changes the background and foreground colours to red and green.",
        "Matt Hawkins",
        "Matt Hawkins",


Download Script

As with all Python scripts the indentation is vitally important! Be-careful when cutting an pasting code. Here is a link to the file so you can download that instead.

GIMP LogoThis can be saved as and copied to the GIMP plugin directory. On my system this is "C:\Program Files\GIMP 2\lib\gimp\2.0\plug-ins".

The line in the script that reads '"<Image>/Filters/MattHawkins/_Hello_World",' should result in a link to the script appearing under the main "Filters" menu, in a sub-section named "MattsBits".

Author : Matt Hawkins  Last Edit By : Matt Hawkins
PHP Powered  MySQL Powered  Valid XHTML 1.0  Valid CSS  Firefox - Take Back The Web  EUKHost - Recommended Webhosting Solutions

MattHawkins CMS v3.0 - Copyright 2009-2017