Adding New Features to the Gimp
As we will see in the last section of this chapter, it is possible to write standalone scripts that communicate with the Gimp as a separate process. First, however, we will concentrate on Gimp-Perl plug-ins that create new filters, special effects, or shortcuts for manipulating images with the Gimp’s user interface. We’ll cover selection areas, layers, undo and redo, pixel regions, and creating alternative user interfaces.
Handling Selections and Layers
The example in this section operates on a region of pixels selected by the user and illustrates the handling of layers and floating layers. It is also a Perl script that acts as a kind of macro for a sequence of actions, with a bit of extra capability such as allowing the option of working on a copy of the image.
The Apply Tint plug-in overlays a colored tone on an image, resulting in a simulated duotone or sepia-tone effect. It is most dramatic on grayscale images, but it also works on RGB images. The final effect may be duplicated manually using the Gimp’s toolbox by following these nine steps:
Convert the image to RGB mode with <Image> → Image → Mode → RGB.
Using one of the selection tools, select the area to be tinted.
Select <Image> → Edit → Copy.
Paste the selection into a new floating selection layer with <Image> → Edit → Paste.
Apply <Image> → Filters → Blur → Gaussian Blur (IIR) with a radius of 5.
Invert the floating layer with <Image> → Image → Colors → Invert.
Use the <Image> → Filters → Colors → ...