Simple interface to writing GIMP plug-ins in Python.

Instead of worrying about all the user interaction, saving last used values and everything, the gimpfu module can take care of it for you. It provides a simple register() function that will register your plug-in if needed, and cause your plug-in function to be called when needed.

Gimpfu will also handle showing a user interface for editing plug-in parameters if the plug-in is called interactively, and will also save the last used parameters, so the RUN_WITH_LAST_VALUES run_type will work correctly. It will also make sure that the displays are flushed on completion if the plug-in was run interactively.

When registering the plug-in, you do not need to worry about specifying the run_type parameter.

A typical gimpfu plug-in would look like this:

from gimpfu import *

def plugin_func(image, drawable, args):
#do what plugins do best
register(

"plugin_func", "blurb", "help message", "author", "copyright", "year", "My plug-in", "*", [


(PF_IMAGE, "image", "Input image"), (PF_DRAWABLE, "drawable", "Input drawable"), (PF_STRING, "arg", "The argument", "default-value")

], [], plugin_func, menu="<Image>/Somewhere")

main()

The call to "from gimpfu import *" will import all the gimp constants into the plug-in namespace, and also import the symbols gimp, pdb, register and main. This should be just about all any plug-in needs.

You can use any of the PF_* constants below as parameter types, and an appropriate user interface element will be displayed when the plug-in is run in interactive mode. Note that the the PF_SPINNER and PF_SLIDER types expect a fifth element in their description tuple – a 3-tuple of the form (lower,upper,step), which defines the limits for the slider or spinner.

If want to localize your plug-in, add an optional domain parameter to the register call. It can be the name of the translation domain or a tuple that consists of the translation domain and the directory where the translations are installed.