Next: 2.7 Combining Layers Up: 2. Review of Layers Previous: 2.5 Floats
Subsections

- 2.6.1 Positioning Layers
  - 2.6.1.1 Moving Layers
  - 2.6.1.2 Aligning Layers with Guides
  - 2.6.1.3 Toggling the Layer Boundary
- 2.6.2 Resizing and Scaling
  - 2.6.2.1 Image Scaling
  - 2.6.2.2 Image Resizing
  - 2.6.2.3 Layer Scaling
  - 2.6.2.4 Layer Resizing
- 2.6.3 Flipping
- 2.6.4 Rotating in 90o Increments
- 2.6.5 The Transform Tool
  - 2.6.5.0.1 Rotation
  - 2.6.5.0.2 Scaling
  - 2.6.5.0.3 Shearing
  - 2.6.5.0.4 Perspective

#
2.6 Manipulating Layers

As already discussed, layers are the most important image components for image manipulation. They are the basic raw materials you want to work with and combine. In most every GIMP project, layers need to be moved, resized, positioned, transformed, cut, pasted, and so on. These types of layer operations are discussed in this section.

##
2.6.1 Positioning Layers

One of the most basic layer operations is positioning. Compositing from a set of raw image materials requires that the various components, each on a separate layer, be appropriately positioned. This section describes several techniques for layer positioning.

###
2.6.1.1 Moving Layers

Moving a layer is accomplished using the `Move` tool. This tool is invoked by clicking on the Toolbox button displaying the four-way arrow icon. Clicking on this tool changes the mouse cursor to a four-way arrow when it is in the image window. Clicking and dragging while the cursor is in the image window causes the layer underneath the mouse cursor to move. The layer affected is the one that is highest in the layer stack and has pixels more than 50% opaque under the mouse cursor (see Section 5.7 for more on opacity and transparency). This means that if the top layer is transparent at the mouse cursor position, it is not moved. This also means that if the active layer is transparent at the mouse cursor position it is not moved. Rather, it is the first layer from the top that has more than 50% opaque pixels under the mouse cursor that is moved. Alternatively, the active layer can be forced to move by Shift-clicking and dragging. This moves the active layer regardless of its visibility, degree of transparency, or position with respect to the cursor.

###
2.6.1.2 Aligning Layers with Guides

Sometimes a layer needs to be positioned more carefully than can be easily judged by eye. Under these circumstances, it is often convenient to use guides to facilitate their placement. Guides are useful because they have a snapping property . A layer released sufficiently near a guide will jump to the guide position. The snapping property of guides is controlled by the `Snap to Guides` checkbox in the `Image:View` menu. The checkbox must be toggled on for the snapping property to work.

To illustrate how guides are useful for layer positioning, the three planet images shown in Figures 2.13(a), (b), and (c)

Figure 2.13: Images to be Aligned with Guides

were each copied and pasted to new layers in a larger image window with a black background. This is shown in Figure 2.14.

Figure 2.14: Images Aligned with Guides

The objective is to organize the planets on a diagonal, but with a uniform black border between them and the window edge. This was done by placing two horizontal and two vertical guides in the image window, each positioned exactly three ruler tick marks from the edge. Where do the guides come from? Well, they are hidden inside the rulers at the left and top edges of the image window. Clicking on a ruler and then dragging the mouse into the image window drags a guide along with it. Releasing the mouse button positions the guide. Any number of guides can be created in this way. Once the guides are positioned, their visibility can be toggled on or off with the `Toggle Guides` function, found in the `Image:View` menu, or by typing `C-S-t` in the image window.

The guides can be seen in Figure 2.14 as blue dashed lines. The Jupiter and Earth layers were positioned with the `Move` tool so that their corners were aligned at the cross-hairs of the guides. It can be seen that the active layer, designated by the yellow dashed boundaries shown in Figure 2.14, are perfectly aligned with the guides. That the layers snapped to the guides simplified the positioning operation. When no longer needed, the guides can be moved off the image by first activating the `Move` tool from the Toolbox and then using the mouse to drag the guides back into the rulers.

###
2.6.1.3 Toggling the Layer Boundary

Careful alignment or color matching between layers is often required for layer edges that are overlapping or abutting. The layer boundaries of the active layer can be seen in the image window, even when the layer contents cannot be seen. This boundary, consisting of a black-and-yellow dashed line, can impede the precision with which alignment and color matching work is performed. Under these circumstances it is useful to visually toggle off the layer boundaries, which is easily done with the `Toggle Selection` function, found in the `Image:View` menu. Alternatively, `C-t` can be typed in the image window. The visibility of the layer boundaries is restored by toggling a second time.

## 2.6.2 Resizing and Scaling

As was seen in Figures 2.2 and 2.10(a), the layers in an image need not all be the same size. Furthermore, changing a layer's dimensions can be quite useful. In the parlance of the GIMP, a layer can be resized, which means that its boundaries are shrunk or enlarged without changing the dimensions of the image's contents. Alternatively, a layer can be scaled, which means that the dimensions of the layer are changed and the image contents are stretched or squeezed to exactly fit within the new layer boundaries. Six functions in the GIMP resize or scale layers and images:

- `Layer Boundary Size`, found in the Layers menu
- `Scale Layer`, found in the Layers menu
- `Canvas Size`, found in the `Image:Image` menu
- `Scale Image`, found in the `Image:Image` menu
- The `Crop` tool from the Toolbox
- The `Transform` tool from the Toolbox

Each of these are discussed and compared in the following sections.

###
2.6.2.1 Image Scaling

Scaling an image results in changing the dimensions of all the layers at once, while simultaneously stretching or squeezing the image contents to fit. The function `Scale Image` , found in the `Image:Image` menu, is the tool that accomplishes this. Figure 2.15(a)

Figure 2.15: Image Scaling

shows an example image, and Figure 2.15(b) shows the `Scale Image` dialog. The new width and height of the image can be specified in pixels or as a percentage of the current dimensions. The default is to scale the two dimensions proportionally, but this can be changed by toggling the chain icon next to the Ratio X and Y entry boxes. The result of scaling down the image shown in Figure 2.15(a) by 75% is shown in Figure 2.15(c). The result of scaling it up by 125% is shown in Figure 2.15(d).

###
2.6.2.2 Image Resizing

At first blush it would seem that the `Canvas Size` function found in the `Image:Image` menu should work in a similar fashion to `Scale Image`. However, there is an important difference between resizing an image and scaling it. Because the image contents do not change with the image boundaries, there is a non-unique choice in how they are positioned within the resized image window. Thus, when resizing to a smaller image window, the position of the image within the new window depends on the values for the new width, height, and X and Y offsets.

Figure 2.16

Figure 2.16: Image Resizing (Original Becomes Smaller)

illustrates how using `Canvas Size` can give rise to an inconvenient problem. Figure 2.16(a) shows the original image, and Figure 2.16(b) shows the `Set Canvas Size` dialog. In the dialog the X and Y ratios have been set to 50% of the original image size. The result is shown in Figure 2.16(c). As can be seen, the image is poorly positioned within the new window. This can be compensated for by using the `Move` tool to reposition the image inside the window. The result of doing this is shown in Figure 2.16(d). However, the result still leaves the image subject, the wolf's head, poorly framed. The problem is that there is no easy way to enter numbers into the `Set Canvas Size` dialog to obtain an aesthetically pleasing result.

A better solution is to resize the image interactively using the `Crop` tool. Figure 2.17

Figure 2.17: Resizing Using the `Crop` Tool

illustrates how the original image can be resized smaller this way. The tool is applied by clicking on the `Crop` tool icon in the Toolbox and then clicking and dragging in the image window to create the crop rectangle. Once drawn, the dimensions of the crop rectangle can be adjusted by clicking and dragging either the upper-left or lower-right corners of the rectangle. The rectangle can also be repositioned by clicking and dragging the upper-right or lower-left corners.

The result of using the `Crop` tool to nicely frame the wolf's head is shown in Figure 2.17(a). When using this tool, the Crop dialog appears, as shown in Figure 2.17(b). It is possible to crop the image by clicking on the Crop button in the dialog or by simply clicking inside the crop rectangle in the image window. This makes the image smaller and simultaneously discards the image parts outside of the window. Alternatively, the image can be resized by clicking on the Resize button in the Crop dialog. This makes the image window smaller without discarding the image parts outside the resulting window.

Figure 2.17(c) shows the result of cropping the image to the crop rectangle seen in Figure 2.17(a). From the above discussion, it should be clear that there is really no reason to use `Canvas Size` to make an image window smaller. It is simply more convenient to do it with the `Crop` tool.

Although `Canvas Size` is not optimum for making an image smaller, it is quite useful for making it larger. This is especially valuable when compositing several raw images. Typically you discover, after positioning various imported layers, that the resulting image window is not large enough to adequately frame the composition. When this happens, `Canvas Size` is the tool that fixes the problem. Figure 2.18

Figure 2.18: Image Resizing (Original Becomes Larger)

illustrates the result of resizing an image.

Figure 2.18(a) shows the original image, and Figure 2.18(b) shows the `Set Canvas Size` dialog box. This time the X and Y ratios are scaled to 125% of the original. The result is shown in Figure 2.18(c). Once the image window has been resized it is possible to reposition the image layer or layers using the `Move` tool.

###
2.6.2.3 Layer Scaling

As has already been discussed in this section, it is possible to scale an entire image. However, it is also possible to scale a single layer within an image. There are two tools for doing this in the GIMP: the `Scale Layer` function, found in the Layers menu, and the `Transform` tool in the Toolbox.

As for entire images, a layer can be scaled either smaller or larger. The most typical use of layer scaling is to adjust the relative size of an image on one layer with respect to an image in another. This is needed for almost every compositing project (for examples, see Chapter 7). When it is necessary to scale a layer smaller, either the `Scale Layer` function or the scaling option of the `Transform` tool will do the trick. However, the `Transform` tool might be preferable because it provides interactive control of the scaling process. `Scale Layer` relies on entering numbers into entry boxes in a dialog. It is difficult to choose the correct dimensions, which leads to repeatedly applying `Scale Layer` and `Undo` until the desired effect is achieved.

The problem of finding the right dimensions to scale a layer can sometimes be solved using the `Measure` tool, which is discussed in more detail in Section 2.6.5. A good example of using the `Measure` tool to determine the appropriate amount to rescale a layer is given in Section 7.5. Alternatively, the `Transform` tool provides interactive visual feedback of the scaling process. In addition, it can be used in conjunction with the `Bezier Path` tool and the Transform Lock icon in the Paths dialog to get very fine, interactive scaling control. The technique for this is discussed in Section 3.4.1, and a relevant example is shown in Section 7.2.

Scaling a layer larger should be avoided if possible, because this operation requires the interpolation of pixel values. Interpolation is an approximation process that creates pixels where there were none before and that, consequently, partially degrades the layer's image quality. Thus, when adjusting the relative sizes of several image components on different layers, it is preferable to scale down the larger components to match the size of the smaller ones rather than vice versa.

In the event that it is necessary to scale a layer larger, it is important to know that a layer cannot be scaled to dimensions larger than those of the existing image boundaries. To scale a layer to dimensions greater than these limits, the image window must first be resized larger using the function `Canvas Size`, previously discussed.

###
2.6.2.4 Layer Resizing

As with scaling, a layer can be resized smaller or larger. This is done with `Layer Boundary Size`, found in the Layers menu. Typically you resize a layer to a smaller dimension to eliminate undesirable parts. However, resizing a layer smaller has the same problem as resizing an image. That is, the subject matter of the layer must be properly positioned within the resulting layer boundaries. For images, the positioning problem was solved using the `Crop` tool, but this will not work for resizing layers. Fortunately there is a simple procedure that produces the same effect and allows for the interactive positioning of the layer contents within the smaller layer boundaries.

Figures 2.19 and 2.20 illustrate

Figure 2.19: Resizing a Layer Smaller: Floating a Rectangular Selection

Figure 2.20: Resizing a Layer Smaller: Anchoring the Float to a New Layer and Deleting the Old Layer

how this is done. The method consists of a four-step procedure:

1.
  The region to be framed in the layer is selected with the `Rectangle Select` tool (see Chapter 3 for more on selections). Figure 2.19(a) shows how a rectangular selection has been made in an image window.
2.
  The selection is then converted to a floating selection using the function `Float` from the `Image:Select` menu or by typing `C-S-l` in the image window. Figure 2.19(b) shows the Layers dialog after the selection has been converted to a float.
3.
  The floating selection is then made into a new layer by choosing the `New Layer` function in the Layers menu or by clicking the `New Layer` button in the Layers dialog. Figure 2.20(a) shows the Layers dialog corresponding to this step.
4.
  The old layer is made active, as shown by the Layers dialog in Figure 2.20(b), and is deleted by clicking on the trash can icon in the button bar.

The result of resizing the layer smaller is shown in Figure 2.21.

Figure 2.21: The Resulting Resized Layer

In Figure 2.21(a) the layer has been resized smaller, which can be seen by the black-and-yellow dashed layer boundary. Figure 2.21(b) shows the resulting Layers dialog. The procedure, as described, allows the layer contents to be carefully positioned within the resized layer.

Although there are good reasons to resize an image larger, it is difficult to imagine a good reason for resizing a layer larger. However, due probably to a rationale of symmetry, a layer can be resized larger. It should be noted that, as for layer scaling, the GIMP does not allow a layer to be resized to dimensions larger than the window boundaries of an image. To resize a layer larger than the current image boundaries, the image must first be resized to accommodate it.

##
2.6.3 Flipping

The active layer can be flipped around its vertical or horizontal axes with the `Flip` tool from the Toolbox. A flip is performed by clicking on the `Flip` tool icon, represented by a two-way arrow in the Toolbox, and then by clicking in the image window. When in the image window, the mouse cursor appears as a two-way arrow that is oriented horizontally for horizontal flips and vertically for vertical flips.

As an example of using the `Flip` tool, Figure 2.22(a)

Figure 2.22: Using the `Flip` tool

shows an image of a pelican and Figure 2.22(b) shows the result after flipping the image horizontally. Note that the Horizontal radio button is selected in the `Tool Options` dialog, as shown in Figure 2.22(c). Selecting the Vertical radio button, as shown in Figure 2.22(e), produces the result in Figure 2.22(d).

Note that if the Horizontal radio button is selected in the `Tool Options` dialog the flip option can be momentarily toggled to Vertical by Control-clicking in the image window. Similarly, if the Vertical radio button is selected in the dialog, the option can be toggled to Horizontal option by Control-clicking in the image window.

##
2.6.4 Rotating in 90o Increments

An image or layer can be rotated in 90o increments using the `Rotate` menus. For an image, use the `Image:Image/Transforms/Rotate` menu shown in Figure 2.23(a).

Figure 2.23: Image and Layer Rotate Menus

For a layer, use the `Image:Layers/Rotate` menu shown in Figure 2.23(b). As you can see, these menus can be used to rotate either the entire image or the active layer by by 90, 180, or 270o.

##
2.6.5 The Transform Tool

General transformations of a layer can be done using the `Transform` tool from the Toolbox. This tool can perform rotation, scaling, shearing, and perspective transformations of the active layer. As usual, care must be taken to specify the active layer before applying this tool.

Figure 2.24(a)

Figure 2.24: Transform Tool Dialog

illustrates an image layer contained in a somewhat larger window. Shown in Figure 2.24(b) is the `Tool Options` dialog, which is obtained by double-clicking the `Transform` tool icon in the Toolbox window. The four radio buttons in the Transform area of the dialog are used to select the desired transformation type, which can be Rotation, Scaling, Shearing, or Perspective.

Transforming a layer requires interpolation of pixel values, and this can introduce some jagged-edge artifacts into the result. The toggle button labeled Smoothing diminishes this effect, which is why it is on by default. It does tend to make the image a little less sharp, though (see Section 6.4.1 for a discussion of how to recover some of the lost sharpness).

The Tool paradigm area of the dialog has two options. The default is Traditional, which maps the image to a transformed grid (see Figure 2.26). For those who like to go against the grain, the Corrective option maps the transformed grid to the image, thus producing an inverse transformation. For example, rotating the transform grid in one direction with the Corrective option maps the grid back to the image, making the image itself rotate in the opposite direction. Sound complicated? It isn't. Just try it yourself and you'll see.

####
2.6.5.0.1 Rotation

Figures 2.25

Figure 2.25: Initiating the Rotation Transformation

and 2.26

Figure 2.26: Finalizing the Rotation Transformation

illustrate the use of the Rotation option of the `Transform` tool. Figure 2.25(a) shows the image layer, and Figure 2.25(b) the `Rotation Information` dialog that appears when the left mouse button is clicked in the image window. The `Rotation Information` dialog has entry boxes that can be used to give a specific angle of rotation as well as the position of the point that will be the center of rotation. By default, the center of rotation is the geometric center of the active layer.

For each of the Transform options, Rotation, Scaling, Shearing, or Perspective, the first mouse click on the image brings up a dialog specific to the chosen option. This mouse click also displays a grid superimposed on the active layer in the image window. The number of grid lines can be controlled from the `Tool Options` dialog (see Figure 2.24(b)). The grid lines can be seen in Figure 2.25(c). Placing the mouse cursor within the active layer in the image window changes the cursor in accordance with the type of transformation to be performed. The image outline and grid can then be transformed by clicking and dragging. The transformation of the grid can be adjusted as many times as desired because the transformation of the image is not initiated until the option transform button is clicked. For example, the Rotate button in Figure 2.26(b) must be clicked to cause the actual rotation of the image.

As the grid is rotated for the Rotate option of the `Transform` tool, the angle is interactively reported in the `Rotation Information` dialog. The rotated outline for an angle of 25o is shown in Figure 2.26(a). As already stated, once the desired angle of rotation is found, the image itself is rotated by clicking on the Rotate button, seen in the dialog shown in Figure 2.26(b). The resulting rotated layer is shown in Figure 2.26(c).

As an alternative to interactively rotating the grid with the mouse, the rotation can also be performed by entering a value into the Angle entry box or by using the slider in the Rotation dialog. Useful values of rotation can be determined with the `Measure` tool. An example of this is illustrated in Section 7.2.

####
2.6.5.0.2 Scaling

Figure 2.27

Figure 2.27: The Scaling Transformation

illustrates the Scaling option of the `Transform` tool. Like for rotation, scaling can be performed interactively with the mouse or by entering values into the Width and Height entry boxes in the Scaling dialog.

Values can be entered into the Scaling dialog in a number of units, the default being pixels. It is often convenient to perform scaling as a percentage of the original dimensions (which are shown at the top of the Scaling dialog as the Original Width and Height). This can be done by choosing the % option from the pull-down menu in the dialog. Figure 2.27(b) shows that this choice was used to scale the grid in Figure 2.27(a) by 50% in both dimensions. When the Scale button in the dialog is clicked, this produces the result shown in Figure 2.27(c).

It is useful to be able to constrain the X and Y scale ratio so as to maintain their aspect ratio when scaling a layer with the `Transform` tool. This is done by pressing both the Control and Alt keys while using the mouse to scale the transform grid. Useful values for scaling can be determined using the `Measure` tool. Section 7.5 illustrates an example of this.

####
2.6.5.0.3 Shearing

Figure 2.28

Figure 2.28: The Shear Transformation

shows the application of the Shearing option of the `Transform` tool. As with the other options, shearing can be applied interactively with the mouse or by entering values into the `Shear Information` dialog. Shearing can be applied either horizontally or vertically, but not in both directions simultaneously. If applied using the mouse, the direction of shear is determined by the mouse's initial direction of movement. Otherwise, it depends on the first entry box used in the dialog.

####
2.6.5.0.4 Perspective

Perspective is perhaps the most intriguing option of the `Transform` tool. This option is illustrated in Figure 2.29.

Figure 2.29: The Perspective Transformation

This is the only transform option where values cannot be directly entered into a dialog. As shown in Figure 2.29(b), there is numerical feedback about how the Perspective transform option is applied to the image, but this is not particularly valuable because it is unclear how to reuse the information. The consequence is that the Perspective option may only be applied interactively with the mouse.

Figure 2.29(a) shows that the grid line feature provides very useful feedback for this particular tool. The lines help visualize the perspective warping that will take place once the Transform button is clicked in the `Perspective Transform` dialog. The perspective transform allows each of the four corners of the layer to be independently repositioned. The resulting image is warped to a general quadrilateral. Figure 2.29(c) shows the result of applying the perspective transform specified by the grid shown in Figure 2.29(a).

It should be noted that all the transforms can be used in conjunction with the Transform Lock option of the Paths dialog. This is extremely useful and is discussed in more detail in Section 3.4.1. A relevant example is shown in Section 7.2.

Next: 2.7 Combining Layers Up: 2. Review of Layers Previous: 2.5 Floats
©2000 Gimp-Savvy.com