3.12. Nástroj Klonovat

Obrázek 14.89. Ikona nástroje Klonovat v Panelu nástrojů

Ikona nástroje Klonovat v Panelu nástrojů

The Clone tool uses the current brush to copy from an image or pattern. It has many uses: one of the most important is to repair problem areas in digital photos, by painting over them with pixel data from other areas. This technique takes a while to learn, but in the hands of a skilled user it is very powerful. Another important use is to draw patterned lines or curves: see Patterns for examples.

If you want to clone from an image, instead of a pattern, you must tell GIMP which image you want to copy from. You do this by holding down the Ctrl key and clicking in the desired source image. Until you have set the source in this way, you will not be able to paint with the Clone tool: the tool cursor tells you this by showing .

If you clone from a pattern, the pattern is tiled; that is, when the point you are copying from moves past one of the edges, it jumps to the opposite edge and continues, as though the pattern were repeated side-by-side, indefinitely. When you clone from an image this does not happen: if you go beyond the edges of the source, the Clone tool stops producing any changes.

You can clone from any drawable (that is, any layer, layer mask, or channel) to any other drawable. You can even clone to or from the selection mask, by switching to QuickMask mode. If this means copying colors that the target does not support (for example, cloning from an RGB layer to an Indexed layer or a layer mask), then the colors will be converted to the closest possible approximations.

3.12.1. Activating the tool

You can activate this tool in several ways:

  • By clicking on the tool icon in Toolbox.

  • By clicking on the tool icon in Toolbox.

  • By pressing the C keyboard shortcut.

3.12.2. Key modifiers (default)

See the Paint tools key modifiers for a description of key modifiers that have the same effect on all paint tools.

Ctrl

The Ctrl key is used to select the source, if you are cloning from an image: it has no effect if you are cloning from a pattern. You can clone from any layer of any image, by clicking on the image display, with the Ctrl key held down, while the layer is active (as shown in the Layers dialog). If Alignment is set to None, Aligned, or Fixed in tool options, then the point you click on becomes the origin for cloning: the image data at that point will be used when you first begin painting with the Clone tool. In source-selection mode, the cursor changes to a reticle cross symbol .

3.12.3. Options

Obrázek 14.90. Mode; Opacity; Brush; Pressure Sensitivity, Fade out, Apply Jitter, Hard Edges

Mode; Opacity; Brush; Pressure Sensitivity, Fade out, Apply Jitter, Hard Edges

Normally, tool options are displayed in a window attached under the Toolbox as soon as you activate a tool. If they are not, you can access them from the image menu bar through WindowsDockable WindowsTool Options which opens the option window of the selected tool.

Mode; Opacity; Brush; Size; Aspect Ratio; Angle; Spacing; Hardness; Dynamics; Dynamics Options; Force; Apply Jitter; Smooth Stroke; Lock brush to view

See the Common Paint Tool Options for a description of tool options that apply to many or all paint tools.

Hard edge: this option gives a hard contour to the cloned area.

Patterns

Image

Image

If you choose Image source, you must tell GIMP which layer to use as the source, by Ctrl-clicking on it, before you can paint with the tool.

If you check Sample merged it's what you see (color made with all the layers of a multi-layer image) that's cloned. If it's unchecked, only the selected layer is cloned. For more information about non-destructive image editing with Sample merged see Sample Merge.

Clicking on the pattern symbol brings up the Patterns dialog, which you can use to select the pattern to paint with. This option is only relevant if you are cloning from a Pattern source.

Alignment

Sloučený vzorek

If this option is not checked (default), Clone tool samples from the active layer.

If this option is checked, Clone tool samples from all layers. This allows you to work in a non-destructive fashion, without modifying original pixels: you create a new layer (transparent) above the image layer; this new layer being active, all cloned pixels will appear in this layer.

Cloned pixels are in the new layer.

The Alignment mode defines the relation between the brush position and the source position.

In the following examples, we will use a source image where the sample to be cloned will be taken, and a destination image where the sample will be cloned (it could be a layer in the source image)

Original images for clone alignment

Obrázek 14.91. We will use the largest brush with the Pencil tool. The source is represented here with a ringed cross.

We will use the largest brush with the Pencil tool. The source is represented here with a ringed cross.

An image with a solid background only. We shall draw three cloning strokes successively.

We will use the largest brush with the Pencil tool. The source is represented here with a ringed cross.

None


None

None clone alignment

Example below: At every new brush stroke, the source goes back to its first position. The same sample is always cloned.

Obrázek 14.92. At every new brush stroke, the source goes back to its first position. The same sample is always cloned.

At every new brush stroke, the source goes back to its first position. The same sample is always cloned.

In this mode, the first click you make when painting sets the offset between the source origin and the cloned result, and all subsequent brushstrokes use the same offset. Thus, you can use as many brushstrokes as you like, and they will all mesh smoothly with one another.

If you want to change the offset, select a new source origin by clicking with the Ctrl key pressed.

Aligned clone alignment

In the example below, at every new brush stroke, the source keeps the same offset it had with the previous brush stroke. So, there is no cloning offset for the first brush stroke. Here, for the following strokes, the source ends up out of the source image canvas; hence the truncated aspect.

Obrázek 14.93. At every new brush stroke, the source keeps the same offset it had with the previous brush stroke. So, there is no cloning offset for the first brush stroke. Here, for the following strokes, the source ends up out of the source image canvas; hence the truncated aspect.

At every new brush stroke, the source keeps the same offset it had with the previous brush stroke. So, there is no cloning offset for the first brush stroke. Here, for the following strokes, the source ends up out of the source image canvas; hence the truncated aspect.

The Registered mode is different from the other alignment modes. When you copy from an image, a Ctrl-click will register a source layer. Then painting in a target layer will clone each corresponding pixel (pixel with the same offset) from the source layer. This is useful when you want to clone parts of an image from one layer to another layer within the same image. (But remember that you can also clone from one image to another image.)

The Registered mode is different from the other alignment modes. When you copy from an image, a Ctrl-click will register a source layer. Then painting in a target layer will clone each corresponding pixel (pixel with the same offset) from the source layer. This is useful when you want to clone parts of an image from one layer to another layer within the same image. (But remember that you can also clone from one image to another image.)

At every brush stroke, the source adopts the position of the mouse pointer in the destination layer. In the following example, the destination layer is smaller than the source layer; so, there is no truncated aspect.

Obrázek 14.94. At every brush stroke, the source adopts the position of the mouse pointer in the destination layer. Here, the destination layer is smaller than the source layer; so, there is no truncated aspect.

At every brush stroke, the source adopts the position of the mouse pointer in the destination layer. Here, the destination layer is smaller than the source layer; so, there is no truncated aspect.

Fixed

Fixed clone alignment

See that the source remains fixed. The same small sample is reproduced identically in a tightened way:

Obrázek 14.95. The source remains fixed. The same small sample is reproduced identically in a tightened way.

The source remains fixed. The same small sample is reproduced identically in a tightened way.

3.12.4. Transparency

Transparency

Cloning translucent black onto white produces gray.

  • Cloning translucent black onto black produces black.

  • Cloning translucent white onto white produces white.

  • Cloning translucent white onto black produces gray.

  • Cloning can never increase transparency, but, unless keep transparency is turned on for the layer, it can reduce it. Cloning an opaque area onto a translucent area produces an opaque result; cloning a translucent area onto another translucent area causes an increase in opacity.

Filter brushes

There are a few non-obvious ways to use the Clone tool to obtain powerful effects. One thing you can do is to create Filter brushes, that is, create the effect of applying a filter with a brush. To do this, duplicate the layer you want to work on, and apply the filter to the copy. Then activate the Clone tool, setting Source to Image source and Alignment to Registered. Ctrl-click on the filtered layer to set it as the source, and paint on the original layer: you will then in effect be painting the filtered image data onto the original layer.

There are a few non-obvious ways to use the Clone tool to obtain powerful effects. One thing you can do is to create Filter brushes, that is, create the effect of applying a filter with a brush. To do this, duplicate the layer you want to work on, and apply the filter to the copy. Then activate the Clone tool, setting Source to Image source and Alignment to Registered. Ctrl-click on the filtered layer to set it as the source, and paint on the original layer: you will then in effect be painting the filtered image data onto the original layer.

History brush

You can use a similar approach to imitate Photoshop's History brush, which allows you to selectively undo or redo changes using a brush. To do this, start by duplicating the image; then, in the original, go back to the desired state in the image's history, either by undoing or by using the Undo History dialog. (This must be done in the original, not the copy, because duplicating an image does not duplicate the Undo history.) Now activate the Clone tool, setting Source to Image source and Alignment to Registered. Ctrl-click on a layer from one image, and paint on the corresponding layer from the other image. Depending on how you do it, this gives you either an undo brush or a redo brush.