Programming Scripts and Plug-ins for GIMP: Introduction

GIMP logo

For several years now, Adobe Photoshop has been the sole reason that I have continued to run Mac OS X. During that time, I have done the majority of my work in an Ubuntu instance running in a Parallels virtual machine. I’ve finally bitten the bullet and installed Ubuntu as the primary operating system on my MacBook Pro. I couldn’t be more pleased with how the transition has gone, and I regret not doing it earlier.

Anyone who has used Linux likely knows of GIMP (GNU Image Manipulation Program). GIMP is the most full featured and mature image editing program available for Linux. (It is also available for OS X and Windows.) I have found it a more than competent replacement for PhotoShop, at least for my tasks, but even the best piece of software is not going to meet everyone’s needs.

If you want to add functionality to GIMP, like creating your own filter, or if you have an imaging processing task that you want to automate, then you need to look to GIMP’s scripting and plug-in systems. Originally there was one way to program custom additions: using Script-fu, a Scheme-like scripting language whose interpreter is built directly into GIMP. Newer to the scene, but still almost a teenager, is Python-Fu, the name given to a set of Python modules that act as a wrapper to libgimp. Unlike Script-Fu code that runs entirely within GIMP, Python-Fu code is run by the Python interpreter, meaning that not only is the entire Python standard library available for use but so are any other modules you have installed.

As a Python fanatic, it was a no-brainer that I would be using Python-Fu to bend GIMP to my will. While both the quantity and quality of Script-Fu documentation and code samples were more than adequate, I found the Python-Fu documentation to be poor, and much of the sample code wouldn’t even run. While the Script-Fu documentation does give some insight as to what functions should be available to Python-Fu, it’s still taken a dive into the Python-Fu source code for me to truly feel like I have a handle on how to write scripts and plugins for GIMP using Python.

In my next post, I will step through writing a simple GIMP plugin using Python-Fu. Stay tuned!






Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.