Gimp-Python is a package that allows people to write plug-ins for The
GIMP in the Python programming
language rather than Script-Fu (Scheme),
Perl, Tcl or C.
While Gimp-Python started life as a 3rd party plug-in, these days it
is distributed as part of The GIMP.
Gimp-Python provides an almost complete wrapper for the libgimp
plug-in library, including support for tiles and pixel regions. This
means that you can use it to do just about everything that is possible
in C, but you get all the benefits of python. You do not have to
worry about freeing data structures, and there are some other benefits
(such as tiles automatically having the dirty flag set when you modify
them). As an example of this power, there is a translation of the
whirl and pinch plug-in included with the package.
The gimp-python wrapper for libgimp is an object oriented one, where
many of the operations on images, drawables, channels and layers
become methods or attributes of those particular types.
Gimp-Python also offers the benefits of script-fu through the gimpfu
module. With this module, you need only write the plug-in function,
make a call to register(), and gimpfu takes care of the GUI (if the
plug-in was called interactively), handle the run_mode parameter, and
save parameter defaults between invocations. This makes writing
plug-ins very easy, while not restricting what they can do.
Among the sample plug-ins, there is a console plug-in. This plug-in
is similar to the script-fu console plug-in, and allows you to
experiment with gimp-python interactively, and programatically modify
There is some documentation for gimp-python in docbook SGML format.
The package contains an HTML conversion as well. Here is an online
copy of the documentation:
Gimp-Python is distributed as part of The GIMP. Depending on the
Linux distribution, it may have been split out into a separate binary
Here is an example of a gimp-python plug-in. It is a translation of
the script-fu clothify plug-in. It is also included in the
from gimpfu import *
def clothify(timg, tdrawable, bx=9, by=9, azimuth=135, elevation=45, depth=3):
width = tdrawable.width
height = tdrawable.height
img = gimp.Image(width, height, RGB)
layer_one = gimp.Layer(img, "X Dots", width, height, RGB_IMAGE,
pdb.plug_in_noisify(img, layer_one, 0, 0.7, 0.7, 0.7, 0.7)
layer_two = layer_one.copy()
layer_two.mode = MULTIPLY_MODE
layer_two.name = "Y Dots"
pdb.plug_in_gauss_rle(img, layer_one, bx, 1, 0)
pdb.plug_in_gauss_rle(img, layer_two, by, 0, 1)
bump_layer = img.active_layer
pdb.plug_in_noisify(img, bump_layer, 0, 0.2, 0.2, 0.2, 0.2)
pdb.plug_in_bump_map(img, tdrawable, bump_layer, azimuth,
elevation, depth, 0, 0, 0, 0, True, False, 0)
"Make the image look like it is printed on cloth",
"Make the specified layer look like it is printed on cloth",
(PF_IMAGE, "image", "Input image", None),
(PF_DRAWABLE, "drawable", "Input drawable", None),
(PF_INT, "x-blur", "X blur", 9),
(PF_INT, "y-blur", "Y blur", 9),
(PF_INT, "azimuth", "Azimuth", 135),
(PF_INT, "elevation", "Elevation", 45),
(PF_INT, "depth", "Depth", 3)
In this simple example, the GUI is automatically generated by gimpfu
module. Only the plug-in function and the call to
to be written by the plug-in author.