Chapter 14. Manipulating Graphics with The GIMP

Contents

14.1. Graphics Formats
14.2. Starting The GIMP
14.3. Getting Started
14.4. Saving Images
14.5. Editing Images
14.6. Printing Images
14.7. For More Information

Abstract

The GIMP (The GNU Image Manipulation Program) is a program for creating and editing raster graphics. In most aspects, its features are comparable to those of Adobe Photoshop and other commercial programs. Use it to resize and retouch photographs, design graphics for Web pages, create covers for your custom CDs, or almost any other graphics project. It meets the needs of both amateurs and professionals.

Like many other Linux programs, The GIMP is developed as a cooperative effort of developers worldwide who volunteer their time and code to the project. The program is under constant development, so the version included in your system may vary slightly from the version discussed here. The layout of the individual windows and window sections is especially likely to vary.

The GIMP is an extremely complex program. Only a small range of features, tools, and menu items are discussed in this chapter. See Section 14.7, “For More Information” for ideas of where to find more information about the program.

14.1. Graphics Formats

There are two main types of graphics—raster and vector. The GIMP is intended for working with raster graphics, which is the normal format for photographs and scanned images. Raster graphics consist of pixels—small blocks of color that together create the entire image. The files can easily become quite large because of this. It is also not possible to increase the size of a pixel image without losing quality. The GIMP supports most common formats of raster graphics.

Unlike raster graphics, vector graphics do not store information for all individual pixels. Instead, it uses geometrical primitives such as points, lines, curves, and polygons. Vector images can be scaled very easily. There are many specialized applications for vector graphics, for example Inkscape. The GIMP has only a very limited support for vector graphics. For example, the GIMP can open and rasterize vector graphics in SVG format or work with vector paths.

14.2. Starting The GIMP

Start The GIMP from the main menu. Alternatively, enter gimp & in a command line.

14.2.1. Initial Configuration

When starting The GIMP for the first time, a configuration wizard opens for preparatory configuration. The default settings are acceptable for most purposes. Press Continue in each dialog unless you are familiar with the settings and prefer another setup.

14.2.2. The Default Windows

Three windows appear by default. They can be arranged on the screen and, except the toolbox, closed if no longer needed. Closing the toolbox closes the application. In the default configuration, The GIMP saves your window layout when you exit. Dialogs left open reappear when you next start the program.

14.2.2.1. The Toolbox

The main window of The GIMP, shown in Figure 14.1, “The Main Window”, contains the main controls of the application. Closing it exits the application. At the very top, the menu bar offers access to file functions, extensions, and help. Below that, find icons for the various tools. Hover the mouse over an icon to display information about it.

Figure 14.1. The Main Window

The Main Window

The current foreground and background color are shown in two overlapping boxes. The default colors are black for the foreground and white for the background. Click the box to open a color selection dialog. Swap the foreground and background color with the bent arrow symbol to the upper right of the boxes. Use the black and white symbol to the lower left to reset the colors to the default.

To the right, the current brush, pattern, and gradient are shown. Click the displayed one to access the selection dialog. The lower portion of the window allows configuration of various options for the current tool.

Under the toolbox, a dialog shows options for the currently selected tool. If it is not visible, open it by double-clicking the tool's icon in the toolbox.

14.2.2.2. Layers, Channels, Paths, Undo

In the first section, use the drop-down box to select the image to which the tabs refer. By clicking Auto, control whether the active image is chosen automatically. By default, Auto is enabled.

Layers shows the different layers in the current images and can be used to manipulate the layers. Information is available in Section 14.5.6, “Layers”. Channels shows and can manipulate the color channels of the image.

Paths are a vector-based method of selecting parts of an image. They can also be used for drawing. Paths shows the paths available for an image and provides access to path functions. Undo shows a limited history of modifications made to the current image. Its use is described in Section 14.5.5, “Undoing Mistakes”.

14.3. Getting Started

Although The GIMP can be a bit overwhelming for new users, most quickly find it easy to use once they work out a few basics. Crucial basic functions are creating, opening, and saving images.

14.3.1. Creating a New Image

To create a new image, select File+New or press Ctrl+N. This opens a dialog in which to make settings for the new image. If desired, select a predefined setting called a Template. To create a custom template, select File+Dialogs+Templates and use the controls offered by the window that opens.

In the Image Size section, set the size of the image to create in pixels or another unit. Click the unit to select another unit from the list of available units. The ratio between pixels and a unit is set in Resolution, which appears when the Advanced Options section is opened. A resolution of 72 pixels per inch corresponds to common screen display. It is sufficient for Web page graphics. A higher resolution should be used for images to print. For most printers, a resolution of 300 pixels per inch results in an acceptable quality.

In Colorspace, select whether the image should be in color (RGB) or Grayscale. For detailed information about image types, see Section 14.5.7, “Image Modes”. In Fill With select the color the image is filled with. You can choose between Foreground Color and Background Color set in the toolbox, White or Transparency for a transparent image. Transparency is represented by a gray checkerboard pattern. Enter a comment for the new image in Comment.

When the settings meet your needs, press OK. To restore the default settings, press Reset. Pressing Cancel aborts creation of a new image.

14.3.2. Opening an Existing Image

To open an existing image, select File+Open or press Ctrl+O. In the dialog that opens, select the desired file. You can also press Ctrl+L and type directly the path to the desired image. Then click Open to open the selected image or press Cancel to skip opening an image.

14.3.3. Scanning an Image

Instead of opening an existing image or creating a new one, you can scan one. To scan directly from The GIMP, make sure that the package xsane is installed. To open the scanning dialog, select File+Acquire+XSane: Device dialog.

Create a preview when the object to scan is smaller than the total scanning area. Press Acquire preview in the Preview dialog to create a preview. If you want to scan only part of the area, select the desired rectangular part with the mouse.

In the xsane dialog, select whether to scan a binary (black and white without shades of gray), grayscale, or color image and the required scan resolution. The higher the resolution you choose, the better the quality of the scanned image. However, this also results in a correspondingly larger file and longer scanning process, due to a higher resolution. The size of the final image (both in pixels and bytes) is shown in the lower part of the dialog.

In the xsane dialog, use the sliders to set desired gamma, brightness, and contrast values. These sliders are not available in binary mode. Changes are visible in the preview immediately. Once all settings have been made, click Scan to scan the image.

14.3.4. The Image Window

The new, opened, or scanned image appears in its own window. The menu bar in the top of the window provides access to all image functions. Alternatively, access the menu by right-clicking the image or clicking the small arrow button in the left corner of the rulers.

File offers the standard file options, such as Save and Print. Close closes the current image. Quit closes the entire application.

With the items in the View menu, control the display of the image and the image window. New View opens a second display window of the current image. Changes made in one view are reflected in all other views of that image. Alternate views are useful for magnifying a part of an image for manipulation while seeing the complete image in another view. Adjust the magnification level of the current window with Zoom. When Shrink Wrap is selected, the image window is resized to fit the current image display exactly.

14.4. Saving Images

No image function is as important as File+Save. It is better to save too often than too rarely. Use File+Save as to save the image with a new filename. It is a good idea to save image stages under different names or make backups in another directory so you can easily restore a previous state.

When saving for the first time or using Save as, a dialog opens in which to specify the filename and type. Enter the filename in the field at the top. For Save in folder, select the directory in which to save the file from a list of commonly used directories. To use a different directory or create a new one, open Browse for other folders. It is recommended to leave Select File Type set to By Extension. With that setting, The GIMP determines the file type based on the extension appended to the filename. The following file types are frequently useful:

XCF

This is the native format of the application. It saves all layer and path information along with the image itself. Even if you need an image in another format, it is usually a good idea to save a copy as XCF to simplify future modifications. Information about layers is available in Section 14.5.6, “Layers”.

PAT

This is the format used for The GIMP patterns. Saving an image in this format enables using the image as a fill pattern in The GIMP.

JPEG

JPG or JPEG is a common format for photographs and Web page graphics without transparency. Its compression method enables reduction of file sizes, but information is lost when compressing. It may be a good idea to use the preview option when adjusting the compression level. Levels of 85% to 75% often result in an acceptable image quality with reasonable compression. Saving a backup in a lossless format, like XCF, is also recommended. If editing an image, save only the finished image as JPG. Repeatedly loading a JPG then saving can quickly result in poor image quality.

GIF

Although very popular in the past for graphics with transparency, GIF is less often used now because of license issues. GIF is also used for animated images. The format can only save indexed images. See Section 14.5.7, “Image Modes” for information about indexed images. The file size can often be quite small if only a few colors are used.

PNG

With its support for transparency, lossless compression, free availability, and increasing browser support, PNG is replacing GIF as the preferred format for Web graphics with transparency. An added advantage is that PNG offers partial transparency, which is not offered by GIF. This enables smoother transitions from colored areas to transparent areas (antialiasing).

To save the image in the chosen format, press Save. To abort, press Cancel. If the image has features that cannot be saved in the chosen format, a dialog appears with choices for resolving the situation. Choosing Export, if offered, normally gives the desired results. A window then opens with the options of the format. Reasonable default values are provided.

14.5. Editing Images

The GIMP provides a number of tools for making changes to images. The functions described here are those most interesting for home users.

14.5.1. Changing the Image Size

Once an image is scanned or a digital photograph is loaded from the camera, it is often necessary to modify the size for display on a Web page or for printing. Images can easily be made smaller either by scaling them down or by cutting off parts of them. Making an image larger is much more problematic. Because of the nature of raster graphics, quality is lost when an image is made larger. It is recommended to keep a copy of your original image before scaling or cropping.

14.5.1.1. Cropping an Image

Cropping an image works like cutting the edges off a piece of paper. Select the crop tool from the toolbox (it resembles a scalpel) or with Tools+Transform Tools+Crop & Resize. Click a starting corner and drag to outline the area to keep.

A small window opens with information about the starting point and the size of the selected area. Adjust these values by clicking and dragging a corner of the crop box or by adjusting the values in the window. From Selection adjusts the crop to fit the current selection (selections are explained in Section 14.5.2, “Selecting Parts of Images”). Auto Shrink makes the crop smaller based on color changes in the image.

Press Cancel to abort the crop. Press Crop to crop the image. The results of Resize are identical to those of Change Canvas Size, described in Section 14.5.1.3, “Changing the Canvas Size”.

14.5.1.2. Scaling an Image

Select Image+Scale Image to change the overall size of an image. Select the new size by entering it in Width or Height. To change the proportions of the image when scaling (this distorts the image), click the chain icon to the right of the fields to break the link between them. When those fields are linked, all values are changed proportionately when the value in one of the fields is changed. Adjust the resolution with X resolution and Y resolution.

Interpolation is an expert option that controls the scale method. When finished adjusting the size, press Scale to scale the image. Reset restores the original values. Cancel aborts the procedure.

14.5.1.3. Changing the Canvas Size

Changing the canvas size is like putting a mat around an image. Even if the mat is smaller, the rest of the image is there, but you can only see part of it. If the mat is larger, you see the original image with extra space around it. To do this, select Image+Canvas Size.

In the dialog that opens, enter the new size. By default, the width and height maintain the same proportions as the current image. To change this, click the chain icon.

After adjusting the size, determine how the existing image should be positioned in comparison to the new size. Use the offset values or drag the box inside the frame at the bottom. When satisfied with the changes, click Resize to change the canvas size. Click Reset to restore the original values or Cancel to cancel the canvas resize.

14.5.2. Selecting Parts of Images

It is often useful to perform an image operation on only part of an image. To do this, the part of the image with which to work must be selected. Areas can be selected using the select tools available in the toolbox, using the quick mask, or combining different options. Selections can also be modified with the items under Select. The selection is outlined with a dashed line, called marching ants.

14.5.2.1. Using the Selection Tools

The main select tools are rather easy to use. The paths tool, which can also be used for more than selecting, is more complicated so is not described here. In the tool options for the other select tools, use one of the icons in the Mode row to determine whether the selection should replace, be added to, be subtracted from, or intersect with an existing selection.

Rect Select

This tool can be used to select rectangular or square areas. In the tool options, select among Free Select, Fixed Size, and Fixed Aspect Ratio to control the shape and size of the selection. To make a square selection in the free select mode, hold Shift while selecting a region.

Ellipse Select

Use this to select elliptical or circular areas. The same options are available as with rectangular selection. Holding Shift during selection produces a circle.

Free Select (Lasso)

Draw a selection area freehand with this tool by dragging the mouse over the image with the left mouse button pressed. The end points will be connected with a straight line when you release the tool. The area inside is then selected.

Fuzzy Select (Magic Wand)

This tools selects a continuous region based on color similarities. Set the maximum difference between colors in the tool options dialog in Threshold.

By Color Select

With this, select all the pixels in the image with the same or similar color as the clicked pixel. The maximum difference between colors can be set in the tool options dialog in Threshold.

Intelligent Scissors

Click a series of points in the image. As you click, the points are connected based on color differences. Click on the first point to close the area. Convert it to a regular selection by clicking inside it.

14.5.2.2. Using the Quick Mask

The quick mask is a way of selecting parts of an image using the paint tools. A good way to use it is to make a rough selection using the intelligent scissors or the lasso (freehand selection tool). Then activate the quick mask by pressing the small icon with the dashed box in the lower left corner.

The quick mask displays the selection using an overlay of red. Areas shaded with red are not selected. Areas appearing as they did before the mask was activated are selected. To modify the selection, use the paint tools. Painting with white selects the painted pixels. Painting with black deselects pixels. Shades of gray (colors are treated as shades of gray) are a partial selection. Partial selection allows smooth transitions between selected and unselected areas.

To use a different color for displaying the quick mask, right-click the quick mask button then select Configure Color and Opacity from the menu. Click the colored box in the dialog that opens to select a new color.

After using the paint tools to adjust the selection as desired, convert from the quick mask view back to the normal selection view by clicking the icon in the lower left corner of the image window (currently displaying a red box). The selection is again displayed with the marching ants.

14.5.3. Applying and Removing Color

Most image editing involves applying or removing color. By selecting a part of the image, limit where color can be applied or removed. When you select a tool and move the cursor onto an image, the cursor's appearance changes to reflect the chosen tool. With many tools, an icon of the current tool is shown along with the arrow. For paint tools, an outline of the current brush is shown, allowing you to see exactly where you will be painting in the image and how large an area will be painted.

14.5.3.1. Selecting Colors

Paint tools use the foreground color. To select the color, first click the display box of the foreground color. A dialog with four tabs opens. These tabs provide different color selection methods. Only the first tab, shown in Figure 14.2, “The Basic Color Selector Dialog”, is described here. The new color is shown in Current. The previous color is shown in Old.

Figure 14.2. The Basic Color Selector Dialog

The Basic Color Selector Dialog

The easiest way to select a color is using the colored areas in the boxes to the left. In the narrow vertical bar, click a color similar to the desired color. The larger box to the left then shows available nuances. Click the desired color. It is then shown in Current. If that color is not what you want, try again.

The arrow button to the right of Current enables saving a number of possible colors. Click the arrow to copy the current color to the history. A color can then be selected by clicking it in the history. A color can also be selected by directly entering its hexadecimal color code in HTML Notation.

The color selector defaults to selecting a color by hue, which is usually easiest for a new user. To select by saturation, value, red, green, or blue, select the corresponding radio button to the right. The sliders and number fields can also be used to modify the currently selected color. Experiment a bit to find out what works best for you.

When the desired color is shown in Current, click OK. To restore the original values shown when the dialog was opened, click Reset. To abort changing the color, click Cancel.

To select a color that already exists in your image, use the color picker tool, the icon for which resembles an eye dropper. With the tool options, set whether the foreground or background color should be selected. Then click a point in the image that shows the desired color. When the color is right, click Close to close the tool's dialog.

14.5.3.2. Painting and Erasing

To paint and erase, use the tools from the toolbox. There are a number of options available to fine-tune each tool. Pressure sensitivity options apply only when a pressure-sensitive graphics tablet is used.

The pencil, brush, airbrush, and eraser work much like their real-life equivalents. The ink tool works like a calligraphy pen. Paint by clicking and dragging. The bucket fill is a method of coloring areas of an image. It fills based on color boundaries in the image. Adjusting the threshold modifies its sensitivity to color changes.

14.5.3.3. Adding Text

With the text tool, easily add text to an image. With the tool options, select the desired font, font size, color, justification, indent, and line spacing. Then click a starting point in the image. A small dialog opens in which to enter your text. Enter single or multiple lines of text then press Close.

The text tool creates text on a special layer. To work with the image after adding text, read Section 14.5.6, “Layers”. When the text layer is active, it is possible to modify the text by clicking in the image to reopen the entry dialog. Change the settings by modifying the tool options.

14.5.3.4. Retouching Images—The Clone Tool

The clone tool is ideal for retouching images. It enables you to paint in an image using information from another part of the image. If desired, it can instead take information from a pattern.

When retouching, it is usually a good idea to use a small brush with soft edges. In this way, the modifications can blend better with the original image.

To select the source point in the image, press and hold Ctrl while clicking the desired source point. Then paint with the tool as usual. When you move the cursor while painting, the source point, marked by a cross, moves as well. If the Alignment is set to Non Aligned (the default setting), the source resets to the original when you release the left mouse button.

14.5.4. Adjusting Color Levels

Images often need a little adjusting to get ideal print or display results. In many programs designed for inexperienced users, the brightness and contrast levels are modified. This can work and is also available in The GIMP, but better results can be obtained by adjusting the color levels.

To do this, select Layer+Colors+Levels. A dialog opens for controlling the levels in the image. Good results can usually be obtained by clicking Auto. To make manual adjustments to all channels, use the dropper tools in All Channels to pick areas in the image that should be black, neutral gray, and white.

To modify a channel individually, select the desired channel in Channel. Then drag the black, white, and middle markers in the slider in Input Levels. Alternatively, use the dropper tools to select points in the image that should serve as the white, black, and gray points for that channel.

If Preview is checked, the image window shows a preview of how the image would look with the modifications applied. When the desired result is achieved, press OK to apply the changes. With Reset, restore the original settings. Cancel aborts level adjustment.

14.5.5. Undoing Mistakes

Most modifications made in The GIMP can be undone. To view a history of modifications, use the undo dialog included in the default window layout or open one from the toolbox menu with File+Dialogs+Undo History.

The dialog shows a base image and a series of editing changes that can be undone. Use the buttons to undo and redo changes. In this way, you can work back to the base image. If you undo a modification then make a new one, the undone modification cannot be redone.

Changes can also be undone and redone with the Edit menu. Alternatively, use the shortcuts Ctrl+Z and Ctrl+Y.

14.5.6. Layers

Layers are a very important aspect of The GIMP. By drawing parts of your image on separate layers, change, move, or delete those parts without damaging the rest of the image. To understand how layers work, imagine an image created from a stack of transparent sheets. Different parts of the image are drawn on different sheets. The stack can be rearranged, changing which parts are on top. Individual layers or groups of layers can shift position, moving sections of the image to other locations. New sheets can be added and others set aside.

Use the Layers dialog to view the available layers of an image. The text tool automatically creates special text layers when used. The active layer is highlighted. The buttons at the bottom of the dialog offer a number of functions. More are available in the menu opened when a layer is right-clicked in the dialog. The two icon spaces before the image name are used for toggling image visibility (eye icon when visible) and for linking layers. Linked layers are marked with the chain icon and moved as a group.

Only layers with transparency (an alpha channel) can be placed above other layers in a stack. To add this to a layer, right-click and select it from the menu.

14.5.7. Image Modes

The GIMP has three image modes—RGB, Grayscale, and Indexed. RGB is a normal color mode and is the best mode for editing most images. Grayscale is used for black-and-white images. Indexed limits the colors in the image to a set number. It is mainly used for GIF images. If you need an indexed image, it is normally best to edit the image in RGB then convert to indexed right before saving. If you save to a format that requires an indexed image, The GIMP offers to index the image when saving.

14.5.8. Special Effects

The GIMP includes a wide range of filters and scripts for enhancing images, adding special effects to them or making artistic manipulations. They are available in Filters and Script-fu. Experimenting is the best way to find out what is available. Xtns in the toolbox includes a number of items for creating buttons, logos, and other things.

14.6. Printing Images

To print an image, select File+Print from the image menu. If your printer is configured in the system, it should appear in the list. In some cases, it may be necessary to select an appropriate driver with Setup Printer. Select the appropriate paper size with Media Size and the type in Media Type. Other settings are available in the Image / Output Settings tab.

Figure 14.3. The Print Dialog

The Print Dialog

In the bottom portion of the window, adjust the image size. Press Use Original Image Size to take these settings from the image itself. This is recommended if you set an appropriate print size and resolution in the image. Adjust the image's position on the page with the fields in Position or by dragging the image in Preview.

When satisfied with the settings, press Print. To save the settings for future use, instead use Print and Save Settings. Cancel aborts printing.

14.7. For More Information

The following resources are useful for users of The GIMP, even if some of them apply to older versions.

  • Help provides access to the internal help system. This documentation is also available in HTML and PDF formats at http://docs.gimp.org.

  • Find many tutorials explaining basic or advanced image manipulation techniques with The GIMP at http://gimp.org/tutorials/.

  • The GIMP User Group offers an informative Web site at http://gug.sunsite.dk.

  • http://www.gimp.org is the official home page of The GIMP.

  • Grokking the GIMP by Carey Bunks is an excellent book based on an older version of The GIMP. Although some aspects of the program have changed, it can provide excellent guidance for image manipulation. An online version is available at http://gug.sunsite.dk/docs/Grokking-the-GIMP-v1.0/.


SUSE Linux Enterprise Desktop GNOME User Guide 10 SP4