The GNU Image Manipulation Program (GIMP) is a powerful imaging tool that is included with Red Hat Linux. One of the intentions of the GIMP is to reproduce most of the features and functionality in an application that is under the GPL. This chapter will provide a brief introduction to the GIMP, with demonstrations of layers and selections.

The GIMP is not a Linux-only application. Far from it, the GIMP also runs on most other UNIX platforms, and a Win32 port actually exists.

Work on the GIMP has also spawned other projects with profound influence upon the Linux community. In particular, the GIMP ToolKit (GTK) has risen out of the GIMP to become the heart of the GNOME project, which is the strongest contender for the Linux desktop.

Free Fonts for the GIMP

The GIMP uses the fonts that are available with X Windows. The X fonts that are included by Red Hat are complete, but lacking in many of the stylized typefaces that graphic artists have come to expect.

Information is available at http://www.gimp.org/fonts.html about font resources for the GIMP. In particular, the Freefonts and Sharefonts can be downloaded and added to the X server to vastly increase the available typefaces. These extra fonts can be downloaded from ftp://ftp.gimp.org/pub/gimp/fonts. These font can also be found on the attached CD-ROM in the /fonts directory.

Assuming that “freefonts-0.10.tar.gz” has been stored in the root user's home directory, the archive can be loaded into the X server with the following commands:

cd /usr/X11R6/lib/X11/fonts
tar xvzf ~/freefonts-0.10.tar.gz
chown -R root.root freefont
cd /etc/X11/fs
awk '
/fonts\/Type1/ { print; print "\t/usr/X11R6/lib/X11/fonts/freefont,"}
! /Type1/
' config > config.new
mv config config.without_free
mv config.new config
/etc/rc.d/init.d/xfs restart

After this script has been executed, enter the following command from within X-Windows to see all the new available fonts:

xlsfonts | grep free

Examine the /usr/X11R6/lib/X11/fonts/freefont directory after installation. Read the license files for any fonts which you use continuously, and follow the instructions found there.

The shareware fonts are also easily installed, although they have more strenuous licensing issues.

Assuming that “sharefonts-0.10.tar.gz” has been stored in the root user's home directory, the archive can be loaded into the X server with the following commands:

cd /usr/X11R6/lib/X11/fonts
tar xvzf ~/sharefonts-0.10.tar.gz
chown -R root.root sharefont
cd /etc/X11/fs
awk '
/fonts\/Type1/ { print; print "\t/usr/X11R6/lib/X11/fonts/sharefont,"}
! /Type1/
' config > config.new
mv config config.without_share
mv config.new config
/etc/rc.d/init.d/xfs restart

After this script has been executed, enter the following command from within X-Windows to see all the new available fonts:

xlsfonts | grep share

One last font collection that can be installed is the URW collection of standard fonts (these fonts are the standard fonts found on many Postscript printers). Assuming that “urw-fonts.tar.gz” has been stored in the root user's home directory, the archive can be loaded into the X server with the following commands:

cd /usr/X11R6/lib/X11/fonts
tar xvzf ~/urw-fonts.tar.gz
chown -R root.root URW
cd /etc/X11/fs
awk '
/fonts\/Type1/ { print; print "\t/usr/X11R6/lib/X11/fonts/URW,"}
! /Type1/
' config > config.new
mv config config.without_urw
mv config.new config
/etc/rc.d/init.d/xfs restart

A Session with GIMP

To run GIMP, start X-Windows, open a terminal window, and run the command gimp. GIMP may also be started with tools available in the X-Window manager (but there are so many such window managers that it would be impossible to document all possible methods here). If GIMP has never been run before (by this user), the following two dialog boxes will be displayed:

The above informational window indicates that a number of GIMP components will be installed in the user's home directory. Press Install to continue.

Press Continue above to proceed with starting the GIMP. The GIMP welcome window will be displayed.

The above dialog box may take some time to initialize all the GIMP components. When the GIMP is started in the future, it will not take so long to initialize. When preparations are complete, the following two windows will appear:

The GIMP Tip of the day window can be safely closed (feel free to browse for more tips before closing). The remaining tool window is the control panel for the GIMP. We will use it now to create a new, blank image. When the File/New option on the GIMP control panel is selected, an image creation dialog box will appear:

Just click the OK button to create the image with default settings. The blank image will appear in a new window, similar to what is shown below:

We are going to apply a gradient fill to the blank image. Before doing so, we should set new foreground and background colors. To change the foreground color, double-click on the large, black rectangle at the bottom of the GIMP control panel. A color selection dialog should appear:

In this example, manual entries have been made in the "RGB" color components which select a very dark shade of grey. The RGB color model says that all visible colors are made up of combinations of the three primary colors (red, green, and blue). When red, green, and blue colors are used in the same intensity, a pure shade of grey will result, as it has here. The other color model, HSV, is not discussed here, but achieving a grey color in this model is done by setting the first two components (the hue and saturation) to zero. When all three RGB values of the foreground color have been set to 40, double-click on the large white rectangle at the bottom of the GIMP control panel to set the background color. The color selection dialog will show white. Change it to a lighter shade of grey with 200 for each red, green, and blue component as shown below:

Once the background color has been set, close the color selection dialog, then select the gradient fill tool on the GIMP control panel. It is shown below, in its selected state (notice also that the foreground and background colors have changed). Double-click on the gradient fill tool button. Its tool options dialog will also appear:

We aren't going to change any of these options, but it is important to see that most tools have a tool options dialog. Close the dialog after it has been examined. Then, select the blank image again. Click and drag within it to draw a line similar to the one below (drag from left to right):

When the line has been drawn and the mouse button released, a gradient fill will be generated:

The colors used in this fill gradually change from one shade to another, which is the general behavior of a gradient fill. Now, we are going to generate a tile pattern upon this fill for an even more interesting background. Within the image, right-click the mouse and select Filters/Artistic/Mosaic as shown below:

The following dialog box will appear. Just click OK to use the default options:

The GIMP will compute for a moment, then transform our image into something like this:

The mosaic pattern has been applied to our background image. Now, we are ready to apply some art to the foreground. First we will generate some text with artistic effects. From the GIMP control panel, choose Xtns/Script-Fu/Logos/Cool Metal as shown below:

Change the Text String option to “GIMP” and the point size to 50. If the free fonts have not been loaded, change the Font to “Charter.” Select OK and the image below will be generated.

We are ready at this point to move the text string into our original image - it will offset the mosaic background rather well. Open the “Layers & Channels” dialog by right-clicking in the image and selecting Dialogs/Layers & Cannels...:

Click on the “eyeball” on the background layer. This turns the background layer off. The image will be displayed without the background. Feel free to experiment by clicking the “eyeballs” of the other layers, but do not proceed until all layers are visible except the background.

Next, ensure the reflection layer is selected (by left-clicking on it), then right-click it to bring up the layer options menu. Select Merge Visible Layers to flatten the three remaining layers into one. A layer merging dialog will be presented - just click OK to use the default options.

When the layers are merged, the “GIMP” and “Shadow” layers will be deleted, and their contents will be combined with the “Reflection” layer. The reflection area in the image will no longer be selected.

Right-click in the image and select the Edit/Copy menu option to prepare the text for transport into the original mosaic image.

Once the image has been copied into the clipboard, select the File/Close menu option to destroy the text image. Select the Close option in the confirmation dialog that is presented.

When the text image is closed, the Layers & Channels dialog should automatically revert to the original mosaic image. We now want to create a new layer in the mosaic image, so click on the button in the lower left corner that has a picture of a white piece of paper with the edge folded (it is highlighted in the Layers & Channels dialog below). Doing so will present the New Layer dialog. Just press enter in this dialog to create a new layer with default settings.

Now, within the image, right-click and select Edit/Paste:

The text should appear in the center of the image, as shown below. When pasted in this way, the material becomes a “floating selection,” not based in any layer (although it will shortly merge with the active layer):

Now, select the mover tool on the GIMP control panel (it is shown selected below). Next, click on the text and drag it to the upper left corner of the screen:

Notice the Layers & Channels dialog has a “floating selection.” Click once with the mover tool in the (approximate) center of the image, and the floating selection will merge with the new layer (which is active).

Now, adjust the “Opacity” slider. As it is adjusted the text will become more transparent. Move the slider to various positions all across the dial:

Return the opacity to 100% and click on the elliptical selection tool in the GIMP control panel (it is shown selected below). Then, draw an ellipse in the middle of the right side of the image (such a selection is shown below, but it may be hard to see).

Within the ellipse, we will generate a “Super Nova” effect. Right-click in the image and select Filters/Light Effects/Super Nova:

Move the center of the super nova so that it is in the approximate center of the ellipse selected earlier, then press OK. The super nova effect will be generated:

The Edit/Undo option (obtained by right-clicking on the image) can be used to remove the super nova effect. The Edit/Redo option will bring it back. Try these options now.

It is important to stress that filters and effects apply only to the current selection. We could have used another mosaic pattern, or any other filter, but these filters would be bounded to the confines of the elliptical selection area.

Next, select the text tool from the GIMP control panel. Move the mouse to a lower portion of the image and left-click. The text tool dialog will be presented. Select the “Caligula” typeface, then enter the text “Is Fun!” in the large white text area at the bottom of the dialog box. Finally, click OK.

The text will appear somewhere in the image. Next, select the mover tool from the GIMP control panel and reposition the text at the lower right corner:

Click in another area of the image to merge the text with the active layer:

Now we should save the image. This is a good time to discuss graphics file formats and their limitations (although a thorough discussion is beyond the scope of this text). To save an image with all layer information intact, use the GIMP “XCF” file format. These XCF files can be very large, since they are storing multiple layers with transparency data.

XCF files, however, are not used for graphics on web pages. The two common web graphics formats are JPEG (which uses a lossy compression format based on the discrete cosine transform) and GIF (which is a lossless format based on the Ziv-Lempel-Welch compression algorithim; while it is lossless, it is limited to 255 colors per image). The PNG graphic format is also becomming popular.

However, when one of these (non-GIMP native) formats is used, only the active layer will be saved. Therefore, when saving graphics for the web in one of these formats, all the layers must be merged prior to writing the image.

First, save the image below using XCF format. Right-click on the image and select File/Save:

Then, select XCF for the file type and enter a name in the text area at the bottom (make sure it ends in “xcf”):

To save this image as a JPEG, first merge all the layers. Right-click on the image and select Layers/Flatten Image:

Then, select Jpeg for the file type and enter a name in the text area at the bottom (make sure it ends in “jpg”):

The JPEG compression settings dialog will appear. Just press OK to select the default compression settings.

This concludes our introduction to the GIMP. There is a great deal more to discover. This tutorial is specifically sparse on the subject of selections. We have not covered freehand selections, selections with Bezier curves, fuzzy selections, intelligent scisors, or selecting by color, nor have additive selections been addressed. The XCF image above can be found in the /fonts directory on the CD-ROM included with this text.

Other Imaging Tools

There are a few other applications which can compliment the use of the GIMP.

Electric Eyes is an application based upon the GIMP TooKit (GTK). It is specifically intended as a tool to display a large sequence of images. It's image editing functions are very limited, and it also has bugs.

ImageMagick is a much older suite of imaging tools. It has an image viewing tool called display (just type display at a shell to start it). A modified version of the display tool called animate will display a sequence of images quickly. A particularly useful component is the convert utility, which will allow images to be converted between different formats directly from the shell, without starting X-Windows. For example, the command convert a.jpg GIF:a.gif converts a JPEG file called “a.jpg” into GIF format. The following shell script will convert all TIFF files in a directory to JPEG images (and was used in the production of this text):

for x in *.tif; do convert $x JPG:`echo $x | sed 's/tif$/jpg/'`; done

XV-3.10a is the oldest and one of the most powerful graphics utilities. For some reason, it is no longer included in Red Hat Linux 6.0. An RPM version of it can still be found in Red Hat Linux 5.2 which works well in 6.0. XV has many strengths, and is second only to the GIMP in functionality. XV was used to create all of the screen captures in this text. Let's hope that Red Hat brings this application back in the next release.