1. GIMP Background
One of the wonderful features of GIMP is that it all its functionality may
be accessed through scripting. So far most of the script programming for
Gimp has been done through Scheme through Script-Fu.
A D V E R T I S E M E N T
Scheme environment Gimp provides is very primitive, e.g. without any
reasonable error handling. Furthermore, must users are not familiar with
scheme as a language. Some users may therefore prefer to write scripts for
the Gimp in Perl.
Perl as a language is probably more familiar to the web-literate users,
as it is the major language for writing CGI scripts. Now, Gimp scripts may
also be written with Perl. This tutorial will describe how to write such
plug-ins and scripts for Gimp.
2. What you need
The Perl::Gimp tutorial scripts have been tested with the following
- Gimp version 1.2 or later, with all its prerequisites.
- Perl version 5.005 or later.
- The perl module Gtk, version 0.7003
- The Gimp module, version 1.201 or later
Perl and all its associated modules are available in source form from the
Perl Comprehensive Archive network, CPAN. It is also possible to download
them in RPM format from the ftp.gimp.org website.
3. The Gimp module
Most scripts make use of the simplified interface Gimp::Fu provided with the
Gimp module. Gimp::Fu provides a framework for entering parameters to the
script in a frame like interface, just like Script-Fu, but also allows
running of the script in batch mode from the command line. This tutorial
will go into detail descriptions of the construction of a Gimp::Fu script,
but before we do this, here is the general framework of a Perl-Fu script.
3: use Gimp ":auto";
4: use Gimp::Fu;
6: # Register extension to gimp
7: register ... ;
9: exit main(); # Handle over control to gimp
The interesting items to note in the script is the use of the two modules
Gimp and Gimp::Fu, the register function, which will be
described in detail below, and the way the control is handed over to
Gimp module on line 9. The use of the ":auto" statement makes
perl automatically include all of the gimp PDB functions and constants into
the perl name space.