Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Mail Systems
Eclipse Documentation

How To Guides
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Problem Solutions




3.7.  Paths

Revision History
Revision $Revision: 1.23 $ 2006-03-21 j.h

Figure 2.23.  Four examples of GIMP paths

Four examples of GIMP paths

Four examples of GIMP paths: one closed and polygonal; one open and polygonal; one closed and curved; one with a mixture of straight and curved segments.

A path is a one-dimensional curve. Paths are used for two main purposes:

  • A closed path can be converted into a selection.

  • An open or closed path can be stroked, that is, painted on the image, in a variety of ways.

Paths can be created and manipulated using the Path tool. Paths, like layers and channels, are components of an image. When an image is saved in GIMP's native XCF file format, any paths it has are saved along with it. The list of paths in an image can be viewed and operated on using the Paths dialog. If you want to move a path from one image to another, you can do so by copying and pasting using the popup menu in the Paths dialog, or by dragging an icon from the Paths dialog into the destination image's window.

Figure 2.24.  Appearance of a path while it is being manipulated using the Path tool.

Appearance of a path while it is being manipulated using the Path tool.

Black squares are anchor points, the open circle is the selected anchor, and the two open squares are its handles. Note that this path has two components.

GIMP paths belong to a mathematical type called “Bezier paths”. What this means in practical terms is that they are defined by anchors and handles. “Anchors” are points the path goes through. “Handles” define the direction of a path when it enters or leaves an anchor point: each anchor point has two handles attached to it.

Paths can be very complex. If you create them by hand using the Path tool, unless you are obsessive they probably won't contain more than a few dozen anchor points (often many fewer); but if you create them by transforming a selection into a path, or by transforming text into a path, the result can easily contain hundreds of anchor points, or even thousands.

A path may contain multiple components. A “component” is a part of a path whose anchor points are all connected to each other by path segments. The ability to have multiple components in paths allows you to convert them into selections having multiple disconnected parts.

Each component of a path can be either open or closed: “closed” means that the last anchor point is connected to the first anchor point. If you transform a path into a selection, any open components are automatically converted into closed components by connecting the last anchor point to the first anchor point with a straight line.

Path segments can be either straight or curved. A path all of whose segments are straight is called “polygonal”. When you create a path segment, it starts out straight, because the handles for the anchor points are initially placed directly on top of the anchor points, yielding handles of zero length, which produce straight-line segments. You can make a segment curved by dragging a handle away from one of the anchor points.

One nice thing about paths is that they are very light in terms of resource consumption, especially in comparison with images. Representing a path in RAM only requires storing the coordinates of its anchors and handles: 1K of memory is enough to hold quite a complex path, but not enough to hold even a 20x20 pixel RGB layer. Therefore, it is quite possible to have literally hundreds of paths in an image without putting any significant stress of your system. (How much stress managing them would put on you is, of course, another question.) Even a path with thousands of segments consumes minimal resources in comparison to a typical layer or channel.

3.7.1.  Paths and Selections

GIMP lets you transform the selection for an image into a path; it also lets you transform paths into selections. For information about the selection and how it works, see the Selection section.

When you transform a selection into a path, the path closely follows the “marching ants”. Now, the selection is a two-dimensional entity, but a path is a one-dimensional entity, so there is no way to transform the selection into a path without losing information. In fact, any information about partially selected areas (i.e., feathering) will be lost when the selection is turned into a path. If the path is transformed back into a selection, the result is an all-or-none selection, similar to what would be obtained by executing "Sharpen" from the Select menu.

3.7.2.  Paths and Text

Figure 2.25.  Text converted to a path

Text converted to a path

Text converted to a path and then transformed using the Perspective tool.

Text converted to a path

The path shown above, stroked with a fuzzy brush and then gradient-mapped using the Gradient Map filter with the “Yellow Contrast” gradient.

A text item created using the Text tool can be transformed into a path using the Create path from text button in the Tool Options for the Text tool. This can be useful for several purposes, including:

  • Stroking the path, which gives you many possibilities for fancy text.

  • More importantly, transforming the text. Converting text into a path, then transforming the path, and finally either stroking the path or converting it to a selection and filling it, often leads to much higher-quality results than rendering the text as a layer and transforming the pixel data.

3.7.3.  Paths and SVG files

SVG, standing for “Scalable Vector Graphics”, is an increasingly popular file format for vector graphics, in which graphical elements are represented in a resolution-independent format, in contrast to raster graphics; in which graphical elements are represented as arrays of pixels. GIMP is mainly a raster graphics program, but paths are vector entities.

Fortunately, paths are represented in SVG files in almost exactly the same way they are represented in GIMP. (Actually fortune has nothing to do with it: GIMP's path handling was rewritten for GIMP 2.0 with SVG paths in mind.) This compatibility makes it possible to store GIMP paths as SVG files without losing any information. You can access this capability in the Paths dialog.

It also means that GIMP can create paths from SVG files saved in other programs, such as Inkscape or Sodipodi, two popular open-source vector graphics applications. This is nice because those programs have much more powerful path-manipulation tools than GIMP does. You can import a path from an SVG file using the Paths dialog.

The SVG format handles many other graphical elements than just paths: among other things, it handles figures such as squares, rectangles, circles, ellipses, regular polygons, etc. GIMP 2.0 cannot do anything with these entities, but GIMP 2.2 can load them as paths.

[Note] Note

Creating paths is not the only thing GIMP can do with SVG files. It can also open SVG files as GIMP images, in the usual way.

  Published under the terms of the GNU General Public License Design by Interspire