Layer Masks

Done using GIMP 2.10.20 on Kubuntu Linux 18.04 LTS

We are continuing our discussion of Layers, and this won’t be the last tutorial on that topic either. Because Layers are the most important part of using GIMP, we need to really get to grips with the subject. One tool that is particularly useful is the Layer Mask, which we will address this time.

Layer Masks are a way to non-destructively modify the opacity of selected areas of a layer. This definition has three key pieces:

  • Non-destructively – When you add a Layer Mask to a Layer, all of your changes take place on the Mask, not on the original layer. Your original layer is still 100% there, and will be unchanged if you remove the Mask later.
  • Modify the Opacity – Last time we looked at Alpha Channels and Opacity settings. This is yet another way to modify the opacity to let other Layers show through the Layer with the Mask.
  • Selected areas – This is key. With Layer Masks you can select areas of the layer in a variety of ways to have transparency, and other areas to have opacity. You can do this using any of the selection tools we have discussed previously, or may of the Paint tools.

So what a Layer Mask does is to place a layer on top of another layer, but linked to it. And on this layer mask you start with a completely opaque layer, then remove the opacity on selected areas to let the underlying layer come through. But unlike other layers you see in lines in the Layer dialog, Layer masks are a sort of add-on to a layer and appear next to it.

I need an image to use as an example, so this time I went to and searched for a “flower close-up” image. Snappygoat advertises that it has around 13 million Public Domain/CC0 images, so I am covered on that score. And each time I download an image for this series I am trying to use a different source so as to illustrate just how much content is out there that you can use without breaking any laws. The image I selected is this one:,1,342. Source is Wikimedia Commons.,1,342. Source is Wikimedia Commons.

And the source for this is Wikimedia Commons, which has 64 million media files. They are not all “public domain” necessarily, there is a combination of CC0 and CC-BY-SA stuff, but you can see the applicable license on the page for an object.

When I open this in GIMP, a layer is automatically created to hold it:

GIMP Layer for image I opened
GIMP Layer for image I opened

Now to create a Layer mask I go down to the bottom to the buttons and pick the next to last one to Add a mask. That will open a pop-up window:

Window to Add a Mask to a layer
Window to Add a Mask to a layer

We’ll get into the other options later, but for right now the thing you want to remember is that White means full opacity and Black means full transparency. That is the key to working on this. I will leave it at the default of White for full opacity, and click Add. Now you will see this in the Layers dialog:

Layer with Layer Mask added
Layer with Layer Mask added

Note that there is now a white rectangle next to the thumbnail of the image. That is the Layer Mask, and it is a distinct object from the image, yet linked to it. You cannot move it up or down in the stack like other layers, it is always on top of the layer you added it to. But because they are distinct you can do things to the Layer Mask without affecting the original layer, which is why we call it non-destructive. To make changes, first right-click on the Layer Mask to select it, and in the pop-up make sure Show Layer Mask and Edit Layer Mask have checkmarks. Your image should now be replaced by a white rectangle that completely obscures the image.

Now remember that White means opacity and Black means transparency, so if you wanted to see some of the original image through the mask, you need to start applying black in some way. The easiest way is probably the paint brush. Make sure your colors are set to White as the background and Black as the foreground, then select the paintbrush. Paint something on the Layer Mask using your black:

Layer Mask with Black paint on it
Layer Mask with Black paint on it

Now, to see the effect, right-click on the layer in the Layer dialog, and select Apply Layer Mask:

Layer Mask Applied
Layer Mask Applied

We can see that the area that was black on the Layer Mask has become transparent on the image. Also, if you note that the brush I used had fuzzy edges, you can see that the transparent area transitions to the opaque area through stages of partial transparency.

Partial Transparency

There is another way to achieve partial transparency/opacity, and that is by painting with a shade of gray, instead of pure black. As the gray gets darker, there is more transparency, and as the gray gets lighter, there is more opacity. To illustrate this we’ll go back to our flower image and apply a layer mask. Next, looking at the usual black and white colors, we see that black has the HTML color value of 000000, and white has the value of ffffff. Each pair of digits represents one of the color channels Red, Green, and Blue. When all three number pairs are equal, we get gray scale colors. So we can look at our Foreground color, which is usually Black when working on a Layer Mask, and adjust the color by typing in new numbers. Here is an example using stripes of partial transparency as follows:

  • 222222 (near transparency)
  • 444444
  • 666666
  • 888888
  • aaaaaa
  • cccccc
  • eeeeee (minimum transparency)
Layer Mask using gray scale stripes of varying transparency
Layer Mask using gray scale stripes of varying transparency

I just drew these stripes freehand, but you can see that in the center of the image the flower is pretty visible, but as you go to the top or bottom it tends to fade away in increasing transparency.

You can use this to get an interesting effect when you stack layers, since transparency lets an underlying layer show through. To do this, open one image and add a layer mask. I did this with our Flower image. Then I used the image of the young ladies,and selected Open as Layers. This does two good things. First, it opens it as a layer in the same GIMP project I am in with the Flower image. If I had used just Open, it would be a separate project. Second, opening as a layer crops the Ladies image to match the existing Flower image, which makes it easier. I moved the Ladies layer to be under the Flower layer, then used my partial transparency on the Layer mask of the Flower image. I first made sure I was active on the Flower image, and clicked the Layer Mask section of the layer (the white rectangle on that line) to make sure I was on the Layer mask. One the Layer line, the rectangle with the White border is the active one, and rectangle with the black border is inactive. Of course, since the Layer Mask is already a white rectangle it is hard to see white border, but if you see a black border around it, just click on it to make it active. I then went to the Select menu and chose Select All to work on the entire image. I changed my Foreground color to 888888, then used the Bucket Fill tool to apply this to the entire image. With this partial transparency I got an image of the ladies with the flower coming through as well:

Layer mask with partial transparency combining two images.
Layer mask with partial transparency combining two images.

This is not the most lovely image ever, but it does illustrate the principle.

Non-Destructive Editing

If you were to check the requested or suggested improvements to GIMP one of the most requested is Non-Destructive Editing. In fact, it is an enhancement that has been asked for so much it made it to the FAQ page:

When will GIMP support any kind of non-destructive editing like adjustment layers, layer filters, and/or full-blown node-based editing?

Currently the plan is to introduce non-destructive editing in GIMP 3.2. This is a huge change that will require rethinking the workflow and parts of the user interface.

Now, given that the current version is 2.10, I am guessing that 3.2 is a few years off.But there is a best practice that you can use to protect yourself, and that is by duplicating a layer and doing your editing on the duplicate, not the original. That way, if your editing creates a hot mess, you can just delete that duplicate layer, and still have your original. And you can do this many times along the way. It is a kind of manual form of Version Tracking that you can do if you are careful to do it. And you can do it with Layer Groups as well. Remember that in your GIMP file you can choose whether any given Layer or Layer Group is visible, and when you go to Export the final image you can just turn off visibility for the layers you don’t want in the image. You could of course delete them, but I think it is better to keep everything. Your *.xcf file is a working file you can return to whenever you need to make changes to an image. So create lots of layers, and keep all of them in your *.xcf file. If you get in the habit of doing this, someday you will be very thankful.


Some years ago when I was a College Professor, I tried to get my students to save their work frequently when working on computers. So one day when I was in the Computer Lab (where I was frequently to be found), a young man was suddenly very upset. It turns out he had just finished his paper (which was due the next morning) and had hit the Print button when the computer crashed. And he had not saved anything. It was really too bad, but I hope he learned a life lesson that day.

 Save as PDF