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:

  1. Convert the image to RGB mode with <Image> → Image → Mode → RGB.

  2. Using one of the selection tools, select the area to be tinted.

  3. Select <Image> → Edit → Copy.

  4. Paste the selection into a new floating selection layer with <Image> → Edit → Paste.

  5. Apply <Image> → Filters → Blur → Gaussian Blur (IIR) with a radius of 5.

  6. Invert the floating layer with <Image> → Image → Colors → Invert.

  7. Use the <Image> → Filters → Colors → ...

Get Perl Graphics Programming now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.