The gimp module contains a number of procedures and functions, as well as the definitions of many gimp types such as images, and the procedural database. This section explains the base level procedures.
There are a number of functions in the gimp module that are used to create the objects used to make up an image in Gimp. Here is a set of descriptions of these constructors:
This procedure creates an image with the given dimensions and type (type is one of RGB, GRAY or INDEXED).
Create a new layer called name, with the given dimensions and type (one of the *_IMAGE constants), opacity (float between 0 and 100) and a mode (one of the *_MODE constants). The layer can then be added to the image with the img.add_layer method.
Create a new channel object with the given dimensions, opacity and colour (one of the *_CHANNEL constants). This channel can then be added to an image.
Create a new display window for the given image. The window will not be displayed until a call to gimp.displays_flush is made.
Create a new parasite. The parasite can then be attached to gimp, an image or a drawable. This is only available in gimp >= 1.1
When any of these objects get removed from memory (such as when their name goes out of range), the gimp thing it represents does not get deleted with it (otherwise when your plugin finished running, it would delete all its work). In order to delete the thing the Python object represents, you should use the gimp.delete procedure. It deletes the gimp thing associated with the Python object given as a parameter. If the object is not an image, layer, channel, drawable or display gimp.delete does nothing.
There are a number of functions that can be used to gather information about the environment the plugin is running in:
Returns the current colour cube.
Returns the current gamma correction.
Returns non-zero if a colour map has been installed.
Returns non-zero if Gimp is using X shared memory.
Returns the file name of the GTK configuration file.
These functions alter the currently selected foreground and background.
Returns a 3-tuple containing the current background colour in RGB form.
Returns a 3-tuple containing the current foreground colour in RGB form.
Sets the current background colour. The three arguments can be replaced by a single 3-tuple like that returned by gimp.get_background.
Sets the current foreground colour. Like gimp.set_background, the arguments may be replaced by a 3-tuple.
These functions perform operations on gradients:
Returns the name of the active gradient.
Sets the active gradient.
Returns a list of the names of the available gradients.
Returns a list of num samples, where samples consist of 4-tuples of floats representing the red, green, blue and alpha values for the sample.
Similar to gimp.gradients_sample_uniform, except the samples are taken at the positions given in the list of floats pos instead of uniformly through the gradient.
These functions either install procedures into the PDB or alert gimp to their special use (eg as file handlers).
For simple plugins, you will usually only need to use register from gimpfu.
This procedure is used to install a procedure into the PDB. The first eight parameters are strings, type is a one of the PROC_* constants, and the last two parameters are sequences describing the parameters and return values. Their format is the same as the param and ret_vals methods or PDB procedures.
This procedure is used to install a procedure into the PDB temporarily. That is, it must be added again every time gimp is run. This procedure will be called the same way as all other procedures for a plugin.
This removes a temporary procedure from the PDB.
This procedure tells Gimp that the PDB procedure name can load files with extensions and prefixes (eg http:) with magic information magics.
This procedure tells Gimp that the PDB procedure name can load files with extensions and prefixes (eg http:).
This procedure tells Gimp that the PDB procedure name can save files with extensions and prefixes (eg http:).
These are the other functions in the gimp module.
This function is the one that controls the execution of a Gimp-Python plugin. It is better to not use this directly but rather subclass the plugin class, defined in the the section called The gimpplugin Module.
The procedural database object.
(Re)Initialise the progress meter with label (or the plugin name) as a label in the window.
Set the progress meter to percnt done.
Returns a list of all the image objects.
Stops execution imediately and exits.
Update all the display windows.
The maximum width of a tile.
The maximum height of a tile.
Set the size of the tile cache in kilobytes.
Set the size of the tile cache in tiles.
Get the information associated with key. The data will be a string. This function should probably be used through the the section called The gimpshelf Module.
Set the information in the string data with key. The data will persist for the whole gimp session. Rather than directly accessing this function, it is better to go through the the section called The gimpshelf Module.
Tells gimp that the plugin has finished its work, while keeping the plugin connection open. This is used by an extension plugin to tell gimp it can continue, while leaving the plugin connection open. This is what the script-fu plugin does so that only one scheme interpretter is needed.
Makes the plugin check for messages from gimp. generally this is not needed, as messages are checked during most calls in the gimp module.
In gimp >= 1.1, it is possible to attach arbitrary data to an image through the use of parasites. Parasites are simply wrappers for the data, containing its name and some flags. Parasites have the following parameters:
The data for the parasite -- a string
The flags for the parasite
True if this parasite is persistent
True if this parasite is undoable
The name of the parasite
Parasites also have the methods copy, is_type and has_flag.
There is a set of four functions that are used to manipulate parasites. They exist as functions in the gimp module, and methods for image and drawable objects. They are:
find a parasite by its name.
Attach a parasite to this object.
Create a new parasite and attach it.
Detach the named parasite