++ed by:

4 PAUSE users
2 non-PAUSE users.

Marc A. Lehmann


Gimp::Fu - easy to use framework for Gimp scripts


  use Gimp;
  use Gimp::Fu;
  (this module uses Gtk, so make sure it's correctly installed)


Currently, there are only three functions in this module. This fully suffices to provide a professional interface and the ability to run this script from within the Gimp and standalone from the commandline.

Dov Grobgeld has written an excellent tutorial for Gimp-Perl. While not finished, it's definitely worth a look! You can find it at http://imagic.weizmann.ac.il/~dov/gimp/perl-tut.html.


In general, a Gimp::Fu script looks like this:

   use Gimp;
   use Gimp::Fu;
   register <many arguments>, sub {
      your code;
   exit main;

(This distribution comes with example scripts. One is examples/example-fu.pl, which is small Gimp::Fu-script you can take as starting point for your experiments)


     "blurb", "help",
     "author", "copyright",
     "menu path",
     "image types",
     sub { code };
function name

The pdb name of the function, i.e. the name under which is will be registered in the Gimp database. If it doesn't start with "perl_fu_", it will be prepended (so all function names registered via Gimp::Fu begin with "perl_fu_")


A small description of this script/plug-in.


A help text describing this script. Should be longer and more verbose than blurb.

The copyright designation for this script. Important! Safe your intellectual rights!


The "last modified" time of this script. There is no strict syntax here, but I recommend ISO format (yyyymmdd or yyyy-mm-dd).

The menu entry Gimp should create. It should start either with <Image>, meaning this script is an image-plug-in, or <Xtns>, for scripts creating new images.

image types

The types of images your script will accept. Examples are "RGB", "RGB*", "GRAY, RGB" etc... Most scripts will want to use "*", meaning "any type".

the parameter array

An array ref containing parameter definitions. These are similar to the parameter definitions used for gimp_install_procedure, but include an additional default value used when the caller doesn't supply one.

Each array element has the form [type, name, description, default_value].

<Image>-type plugins get two additional parameters, image (PF_IMAGE) and drawable (PF_DRAWABLE). Do not specify these yourself. Also, the run_mode argument is never given to the script, but its value canm be accessed in the package-global $run_mode. The name is used in the dialog box as a hint, the description will be used as a tooltip.

See the section PARAMETER TYPES for the supported types.

the code

This is either a anonymous sub declaration (sub { your code here; }, or a coderef, which is called when the script is run. Arguments (including the image and drawable for <Image> plug-ins) are supplied automatically.

It is good practise to return an image, if the script creates one, or undef, since the return value is interpreted by Gimp::Fu (like displaying the image or writing it to disk). If your script creates multiple pictures, return an array.



Are all mapped to a string entry, since perl doesn't really distinguish between all these datatypes. The reason they exist is to help other scripts (possibly written in other languages! really!). It's nice to be able to specify a float as 13.45 instead of "13.45" in C! PF_VALUE is synonymous to PF_STRING.


Will accept a colour argument. In dialogs, a colour preview will be created which will open a colour selection box when clicked.


A gimp image. Not yet supported in dialogs :(


A gimp drawable (image, channel or layer). Not yet supported in dialogs :(


An experimental value used to denote fonts. At the moment, this is just a PF_STRING. It might be replaced by a font selection dialog in the future.

Please note that the Gimp has no value describing a font, so the format of this string is undefined (and will usually contain only the family name of the selected font).


A boolean value (anything perl would accept as true or false). The description will be used for the toggle-button label!


This module is experimental and unfinished.


Marc Lehmann <pcg@goof.com>


perl(1), Gimp,

2 POD Errors

The following errors were encountered while parsing the POD:

Around line 17:

=cut found outside a pod block. Skipping to next block.

Around line 284:

=cut found outside a pod block. Skipping to next block.