How to Use Layer Mask in GIMP

The process of masking originates in the world of physical art, as a way of controlling where paint is applied to your medium. The idea is so useful that it was replicated for the computer back in the early days of digital image editing, and it now forms an integral part of non-destructive editing techniques.

GIMP offers a decent set of masking tools, although they can be a bit confusing to use if you don’t know all the tricks. But don’t worry, masking is simple enough once you know the basics!

A layer mask of a hawk in flight, temporarily made visible in GIMP 2.10

The Quick Guide to Masking in GIMP

Here’s how to create a basic layer mask in GIMP:

  • Step 1: In the Layers panel, right-click the layer you want to mask and choose Add Layer Mask.
  • Step 2: Set the Initialize the Layer Mask option to White (Full opacity).
  • Step 3: Click the layer mask thumbnail in the Layers panel to make it active, and use the Paintbrush tool to paint black and/or white pixels on your layer mask. 

If you’ve already used masking in a different editing program, that’s probably all you need to get going on your project in GIMP. But if you’re new to the world of masking and you want to understand how they work in more detail, then read on. I’ll also include a couple of handy tips for making the masking process much easier! 

How Does Masking Work?

A mask is a kind of invisible secondary layer that sits over the top of a standard pixel layer, controlling which areas of the underlying pixel layer are visible. Technically, it works by modifying the layer’s alpha channel, which controls the transparency of the layer. 

If you paint white pixels on a layer mask, the corresponding area of the standard pixel layer becomes visible, while painting black pixels makes the corresponding area transparent. Various shades of gray allow the creation of partially transparent areas, depending on how light or dark the gray tones are.

The mask itself isn’t visible in the final image, but it can be displayed temporarily while working within GIMP to give you an idea of which areas are masked and which aren’t. I find GIMP’s handling of this aspect to be a bit of a drawback, but I’ll show you some simple ways around the problem later on in the tutorial. 

Why You Should Use Masks in GIMP

Along with general pixel layers and adjustment layers, masking is a key element of a non-destructive editing workflow. If you’re not familiar with the term, it’s actually pretty simple: image data should be altered dynamically instead of permanently. 

In other words, don’t destroy your original pixel data!

If you want to remove pixels from an image, it’s better to hide them than to delete them. If you want to adjust pixels, it’s better to use a separate overlay that changes them instead of actually changing the original pixels. 

With non-destructive editing, if you need to go back and adjust your edit at a later time, you can do so easily because the underlying source image pixels haven’t actually changed. 

For example, if you want to trim unwanted pixels surrounding the subject in an image, you should use a layer mask to hide those pixels instead of actually deleting them. 

If you have to go back later and change which pixels have been trimmed, you can simply adjust the layer mask to control which pixels are visible instead of starting the entire trimming process all over from the beginning. 

GIMP doesn’t allow for a completely non-destructive workflow because it doesn’t offer adjustment layers that apply filters non-destructively the way many other programs do, but you can certainly use layer masks for pixel trimming. This is especially useful when creating complex composite images from multiple different image sources. 

The Detailed Guide to Masking in GIMP

Now that you know how masking works and why it’s an important technique to use, let’s take a closer look at the practical side of masking in GIMP. 

Step 1: Adding A Layer Mask

Before you can start masking, you’ll need to add a layer mask. As with most things in GIMP, there are several ways you can do this, but the simplest is to right-click the layer you want to mask in the Layers panel and choose Add Layer Mask from the popup menu. 

You can also select the layer in the Layers panel and use the Add Layer Mask button from the row at the bottom of the panel, or use the Layers menu – but the right-click method is usually faster. 

The Add Layer Mask dialog box in GIMP 2.10

GIMP will open the Add Layer Mask dialog box, prompting you to choose the initial settings for the mask.

The most common choices are White (Full opacity) and Black (Full transparency), but you’ll have to decide which is best for your particular situation. When you’re just starting out with masking, it’s usually easiest to choose White (Full opacity), so I will continue with that setting for the rest of the tutorial.

This will keep the layer fully visible until you start painting with black pixels onto the layer mask, hiding the parts of the image that you don’t want to keep. 

If you choose Black (Full transparency), the layer will immediately be completely masked out and hidden, which makes it much harder to work with because you can’t see the layer contents while painting your mask. 

(If you can’t wait, I’ve got a few tips to share on how to deal with this issue later on down the post!)

Click the Add button, and GIMP will add the layer mask to your selected layer. If you look at the Layers panel, you’ll see that a new thumbnail has appeared next to the existing layer thumbnail. It should be completely white at the moment, but that will change as we continue. 

Step 2: Painting Your Mask

Click the new layer mask thumbnail in the Layers panel to make it active, otherwise, you’ll wind up painting black and white pixels on your actual image instead of your layer mask. GIMP adds a white selection border to indicate which element is selected, although it can be difficult to tell when the edges of your mask are also all white. 

The layer mask is now selected, although I can’t understand why the GIMP team chose to use a white border as the indicator

With the layer mask selected, all that remains is to start painting. Switch to the Paintbrush tool using the toolbox or the keyboard shortcut P. Make sure that you’re painting with white and black by clicking the small black and white color boxes below the Foreground/Background color display area at the bottom of the toolbox. 

The small black and white squares will reset the foreground and background colors

To quickly switch between painting black and painting white, hit the X key to swap your foreground and background colors. Painting black will hide the corresponding pixels, painting white will make them visible again, and shades of gray will allow for partial transparency. 

Combining Masking and Selections

If traditional masking feels like it will take too long, you can use selections to speed up your masking process. In the example from this post showing the Red-tailed Hawk in flight, masking around all of those feathers is time-consuming and a bit tedious (although I find there is a certain meditative feel to masking by hand if you’ve got the time).

But because it’s highlighted so perfectly against a fairly uniform background, the whole masking process can be sped up using the Fuzzy Select tool. 

A single click with the Fuzzy Select tool on the background of clouds creates a fairly decent selection border around the hawk, and I can use that selection as a base for my mask.

With a selection active, when you add your layer mask, choose Selection from the list. Since I want the hawk to be visible, not the clouds, I’ll enable the Invert mask option, but this can be corrected easily if you accidentally make a mistake. 

Oops! The selection edge was fine, but the wrong part of the image was actually selected

If you find yourself in this situation, first you’ll need to deselect all your pixels with the Select None command, either by using the Select menu or the keyboard shortcut Ctrl + Shift + A.

Next, click the layer mask thumbnail in the Layers panel to make sure it’s selected, then open the Colors menu and click Invert. This will flip the black and white pixels in your layer mask automatically, and the clouds in my image disappear while the hawk pops back into view. 

Much better!

Whenever you create a mask using selections, it’s important to go over the mask carefully and make sure that your edges line up properly. In more complex scenes, the Fuzzy Select method won’t always work as perfectly as in this example, but it can still save you a lot of time. 

Alternative Masking With Quick Mask Mode

There are some situations where GIMP’s default masking workflow doesn’t work as well as you might like, so there’s an alternative method that uses a more modern approach to masking: Quick Mask mode.

Quick Mask mode allows you to see both your mask and the image at the same time by using a red-tinted overlay. This might not work too well on a heavily red-tinted image, but you can adjust the overlay color in the Preferences panel. 

When you’re finished masking using Quick Mask, you’ll wind up with a selection area around your mask. Then you can use the Initialize Mask to: Selection option outlined in the previous section to create a permanent layer mask. 

To start using Quick Mask mode, open the Select menu and choose Toggle Quick Mask. You can also use the keyboard shortcut Shift + Q

Quick Mask mode, showing the default transparent red overlay

The partially transparent red overlay appears over the whole image. You’ll still use the Paintbrush tool with black and white colors to control the mask, but only areas that are still red when you’re finished will form your selection. 

The hawk when masked fully in Quick Mask mode

Once you’re happy with your mask, run the Toggle Quick Mask command from the Select menu again, or press Shift + Q again. This will convert your quick masked areas into a selection, which can then be converted into a permanent layer mask. 

A Final Word

You’ve probably realized by now that masking can be an incredibly involved process, but it’s worth it. The basic principles are fairly simple, but it can take a lot of practice for masking to feel really natural and intuitive. You’ll get there, as long as you’re willing to put the time and effort in.

As you get more comfortable with using selections, Quick Mask, and layer masks in general, you’ll figure out your own workflow that suits your personal approach to editing. But now you know the basics of how to mask in GIMP!

Happy masking!

About Thomas Boldt
I’ve been working with digital images since the year 2000 or so, when I got my first digital camera. I've tried many image editing programs. GIMP is a free and powerful software, but not exactly user-friendly until you get comfortable with it, and I wanted to make the learning process easier for you here.

Leave a Reply

Your email address will not be published. Required fields are marked *

  • Rich Laban

    Outstanding explanation. I’m a newb at 70 yrs old and have struggled with the concept of layer masks, particularly the white and black options. Your article help gel these terms in a way I can understand better. Thank very much.

    Reply
    • Thomas Boldt

      You’re welcome, Rich! Glad you found it helpful. Layer masks are an excellent tool once you get used to working with them.

      Reply
  • Paul Guster

    Hi Tom, thanks for the article. You might want to reread it and perhaps make some changes since I found you have swapped the options in your text explanation e.g., White (full transparency) which I think should be (full opacity) and ditto with Black. Unless I’m even more cognitively challenged than I thought and just don’t understand what you are trying to say.
    I did some experimenting to figure it out but you had me thinking!

    Reply
    • Thomas Boldt

      Hi Paul, you’re absolutely right! I think I wrote the words ‘transparency’ and ‘opacity’ so many times during this post that my brain turned to mush during the review phase, lol =) Thanks for the help!

      Reply