In this chapter, we explain the concepts underlying GIMP scripts and plug-ins and show you how to find and install new ones. Then we briefly describe some important plug-ins that are worth installing. Finally, we show examples of plug-ins written in Python and C, as well as a script written in Scheme.
Another difference between a script and a plug-in is the programming language in which the components are written. Scripts are written in Scheme (called Script-Fu in GIMP) and stored in the Scripts
folder. Plug-ins are written in Python or C and stored in the Plug-Ins
folder.
Scheme is a very simple and rather old language, directly interpreted without any translation needed. GIMP includes an interpreter for a subset of Scheme, so Scheme scripts are always operational. In fact, many of the predefined plug-ins you’ve used so far (for example in Chapter 12 or in Chapter 17) are in fact scripts programmed in Scheme. Scheme is a functional language that uses only parentheses and whitespace for syntactic punctuation.
Python, also directly interpreted, is more powerful than Scheme. It has become popular in the last few years and is probably progressively replacing another scripting language, Perl, because of its much more pleasant syntax and its wider range of capabilities. Python’s interpreter is not part of GIMP and needs to be installed separately on Windows. (It comes packaged with Linux and Mac operating systems.)
C is the language in which the core of GIMP is programmed, as well as most of the GNU/Linux operating system. An old language, C is extremely well supported because it allows programs to use all the capabilities of the computer efficiently. Programs written in C cannot be directly executed but must first be translated into machine language and then loaded. You do this with a compiler. In order to write a C plug-in, you must have a C compiler and development environment on your computer. A compiler is easy to set up on GNU/Linux and Mac OS but a bit trickier on Windows.
GIMP plug-ins can be written in other programming languages, especially if the language is compiled. Perl used to be the language of choice for writing GIMP plug-ins but is used less frequently today. For this reason, we consider only Scheme, Python, and C. To write your own plug-in, you need some knowledge of at least one of these languages; a complete introduction to programming in each language is beyond the scope of this book.
To find out which plug-ins are already a part of your GIMP installation, use the Plug-in Browser (Image: Help > Plug-in Browser), as shown in Figure 21-1. As you can see, this installation has 345 plug-ins. The first tab on the left lists them alphabetically.
When you begin typing in the SEARCH field at the top left of the Plug-in Browser, the plug-ins list is automatically filtered to the names that contain this substring, as shown in Figure 21-2. Click the broom at the top right to clear the filter.
The second tab offers a tree view of all plugins, which can be useful for searching plug-ins by category. In Figure 21-3, we’ve enlarged this view by clicking and dragging its right boundary. As you can see, this view shows the image types accepted by each plug-in, as well as the installation date. In the image types, the letter A means that there is an Alpha channel, and the star is a wildcard. For example, RGB* means that the Alpha channel may or may not be present.
The right part of the dialog describes the plug-in selected at the left. For example, in Figure 21-4, you see the description of the Antialias tool, which is found in Image: Filters > Enhance.
The main source of existing GIMP plug-ins is the GIMP Plugin Registry at http://registry.gimp.org/. Here you’ll find plug-in descriptions, links to the plug-in itself or to its home page, and tags that help in searching. Click a tag for a list of all matching plug-ins.
One convenient way to browse the registry is the Content by tags view (also called tag cloud view), which shows a list of all the tags with a font size proportional to their frequency, as shown in Figure 21-5. The tags are clickable, so browsing all the plug-ins related to a given tag is easy.
Most plug-ins have a very detailed and complete home page, explaining how they work and how to install them.