3.4. 油漆桶填充

图 14.62. Toolbox Fill

Toolbox Fill

This tool fills a selection with the current foreground color. If you Ctrl+click and use the Bucket tool, it will use the background color instead. Depending on how the tool options are set, the Bucket Fill tool will either fill the entire selection, or only parts whose colors are similar to the point you click on. The tool options also affect the way transparency is handled.

The amount of fill depends on what Fill Threshold you have specified. The fill threshold determines how far the fill will spread (similar to the way in which the magic wand works). The fill starts at the point where you click and spreads outward until the color or alpha value becomes too different.

When you fill objects in a transparent layer (such as letters in a text layer) with a different color than before, you may find that a border of the old color still surrounds the objects. This is due to a low fill-threshold in the Bucket Fill options dialog. With a low threshold, the bucket tool won't fill semi-transparent pixels, and they will stand out against the fill because they have kept their original color.

If you want to fill areas that are totally transparent, you have to make sure that the Lock option (in the Layers dialog) is unchecked. If this option is checked, only the non-transparent parts of the layer will be filled.

3.4.1. Activating the tool

  • You can find the Bucket Fill tool from the image-menu through: ToolsPaint ToolsBucket Fill

  • You can also call it by clicking the tool icon: in the toolbox.

  • or by pressing the Shift+B keys.

3.4.2. Key modifiers

  • Similarly to paint tools, pressing Ctrl allows you to pick surrounding colors on canvas without having to switch to Color Picker tool.

  • Shift toggles the use of Fill Similar Color or Fill Whole Selection on the fly.

  • Alt toggles Fill type between FG and BG colors.

3.4.3. 选项

图 14.63. Bucket Fill tool options

Bucket Fill tool options

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

See Paint Tools for help with options that are common to all these tools. Only options that are specific to the Bucket Fill tool are explained here.

Fill Type

GIMP provides three fill types:

FG Color Fill

sets the fill color to the currently selected foreground color.

BG Color Fill

sets the fill color to the currently selected background color.

Pattern Fill

sets the fill color to the currently selected pattern. You can select the pattern to use in a drop down list.

This drop-down list allows the user to select one of many fill patterns to use on the next fill operation. The manner in which the list is presented is controlled by the four buttons at the bottom of the selector.

Affected Area
  • Fill whole selection makes GIMP fill a pre-existent selection or the whole layer. A quicker approach to do the same thing could be to click and drag the foreground, background or pattern color, leaving it onto the selection. Also, pressing Ctrl key allows you to pick a color on the image as foreground color.

  • Fill similar colors: this is the default setting: the tool fills the area with a color near the pixel onto you have clicked. The color similarity is defined by options in Finding Similar Colors.

  • Fill by line art detection:This is a new algorithm in GIMP-2.10.10 allowing you to fill areas surrounded by line arts, trying to leave no unfilled pixels near the lines, and closing potential zones.

    Line art detection is also known as Smart Colorization. The author describes clearly problems he met in https://girinstud.io/news/2019/02/smart-colorization-in-gimp/. Options are described bellow.

寻找相近的颜色

These options appear when the Fill similar colors option is checked:

  • The option Fill Transparent Areas offers the possibility of filling areas with low opacity.

  • The option Sample Merged toggles the sampling from all layers. If Sample Merged is active, fills can be made on a lower layer, while the color information used for threshold checking is located further up. Simply select the lower level and ensure that a layer above is visible for color weighting.

  • To understand what diagonal neighbors are, please refer to Diagonal-neighbors> in Fuzzy Select tool.

  • Please refer to Antialiasing in Glossary.

  • The Threshold slider sets the level at which color weights are measured for fill boundaries. A higher setting will fill more of a multi colored image and conversely, a lower setting will fill less area.

  • With the Fill by option you can choose which component of the image GIMP shall use to calculate the similarity and to determine the borders of filling.

    The components you can choose from are Composite, Red, Green, Blue, Alpha, HSV Hue, HSV Saturation, HSV Value, LCh Lightness, LCh Chroma, LCh Hue,

    This option is not easy to understand. You have chosen, for example, the Red channel. When you click on any pixel, the tool searches for contiguous pixels similar for the red channel to the clicked pixel, according to the set threshold. Here is an example:

    Original image: three strips with gradients of pure colors. Red (255;0;0), Green (0;255;0), Blue (0;0;255). We are going to use the Bucket-fill tool with the magenta color and a Threshold set to 15.

    Image 1: Fill By = Composite. We successively clicked in the three color strips. Every strip is filled according to the threshold.

    Image 2: Fill By = Red. We clicked in the red strip. The tool searches for contiguous pixels which have a similar value in the red channel, according to the set threshold. Only a narrow area corresponds to these standards. In the green and the blue strip, the value of pixels in the red channel is 0, very much different from the red channel value of the clicked pixel: the color doesn't spread to them.

    Image 3: Fill By = Red. We clicked in the green strip. There, the value of the clicked pixel in the red channel is 0. All pixels in the green and the blue strips have the same red channel value (0): they are all painted.

    图 14.64. Example for Fill By

    Example for Fill By

    Original image

    Example for Fill By

    Image 1

    Example for Fill By

    Image 2

    Example for Fill By

    Image 3


Line Art Detection options

图 14.65. Fill by line art detection example

Fill by line art detection example
Fill by line art detection example

Bucket fill tool applied by click-and-drag with default options.They don't well fit this image, especially on eyebrows that are almost wiped off.


  • Source: by default, information for line art computation is taken from all visible layers; you can choose another source:

  • Fill transparent areas: fills completely transparent regions.

  • Feather edges: feathers fill edges.

  • Maximum growing size: maximum number of pixels grown under the line art. Increasing this value makes lines thinner.

    To improve eyebrows in the example, Maximum growing size is reduced to 1.

  • Line art detection threshold: threshold to detect contour (higher values will detect more pixels).

  • Maximum gap length : maximum gap (in pixels) in line art which can be closed.

3.4.4. Fill a feathered selection

By clicking repeatedly in a selection with feathered edges, you progressively fill the feathered border:

图 14.66. Example for Fill a feathered Selection

Example for Fill a feathered Selection

Original image

Example for Fill a feathered Selection

After clicking 3 times more with the Bucket-Fill tool