Episode: 3310 Title: HPR3310: Layer Masks Source: https://hub.hackerpublicradio.org/ccdn.php?filename=/eps/hpr3310/hpr3310.mp3 Transcribed: 2025-10-24 20:34:38 --- This is Haka Public Radio episode 3,310 for Friday 9th of April 2021. Today's show is entitled, Leia Max and in part of the series Gimp, it is hosted by AYUKA and in about 16 minutes long and Karina Cleanflag. The summer is, we begin our look at a key tool in Gimp, Leia Max. This episode of HPR is brought to you by an Honesthost.com. Get 15% discount on all shared hosting with the offer code HPR15. That's HPR15. Better web hosting that's Honest and Fair at An Honesthost.com. Hello, this is AYUKA, welcoming you to Hacker Public Radio and another exciting episode. And we're going to continue our look at Gimp and the topic for today is Leia Masks. This is our continuing discussion of layers. This won't be the last on that topic either. And that's because layers are really the most important part of using Gimp. And so we really need to get to grips with the subject. One tool that is particularly useful is the Leia Mask, which is what we're going to address today. Now, layer masks are a way to non-destructively modify the opacity of selected areas of a layer. Now this definition has three key pieces. First one, 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. Now 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 and gradations between those two extremes, you can do this using any of the selection tools we've discussed previously or many 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, you start with a completely opaque layer. Then you remove the opacity on selected areas to let the underlying layer come through. But unlike other layers you see as individual lines in the layer dialogue, layer masks are a sort of add-on to a layer and appear next to it on the same line. Now I need an image and as you've noticed I try to use different sources for my images. Each time I do this and part of the reason is that I just want to make sure people are aware of how many places you can get images without violating copyright. And there's a lot of good stuff out there. So I went to a site called snappygoats.com and searched for a flower close-up image. Now snappy goat advertises that has around 13 million images that are either public domain or CC zero. So I'm covered on that score. And each time I download an image for this series I say, I'm I'm trying to use different sources. So the image I selected is this one. There's a link in the show notes and you can see it on my website. It's an image of a violet-covered flower. So the source here is Wikimedia Commons and they have 64 million media files. They're not all public domain necessarily. There's a combination of CC by SA and CC zero stuff. But you can see the applicable license on the page for an object. Now when I open this in GIMP a layer is automatically created to hold it. We've talked about that before. Opening images in GIMP creates a layer. Now to create a layer mask I go to the bottom to the buttons and pick the next to last one on the right which is add a mask. Now remember in GIMP you can move the cursor over a button and the tooltip will tell you what it is. So I add a mask that's going to bring up a pop-up layer and you know the pop-up window initialize layer mask 2 and I'll say white. White is full opacity. Now what you want to always be aware of in working with layer masks is that white means full opacity and black means full transparency. That's the key to working on this. Now I'll leave it at the default of white for full opacity and click add. So when I do that I will see now a white rectangle thumbnail right next to the image thumbnail all on one line in the layer dialog in the layer window. Note that there's a layer mask. It's a distinct object from the image and yet linked to it. You cannot move it up and down in the stack like other layers. I mean you can move the layer and the layer mask together up and down in the stack but you cannot separately move the layer mask. But because they're distinct you can do things to the layer mask without affecting the original layer which is why we call it non-destructive. Now to make changes first right click on the layer mask to select it and you'll know it's selected because it'll be all white. There won't be any kind of black border. The layer that is active that is selected always has a white border and any other layers will have black borders. Now since this is a white rectangle to begin with the white border is essentially no border as far as looking at it. Now you select it and in the popup make sure it says show layer mask and edit layer mask and that they have check marks in them. Your image should now be replaced by a white rectangle that completely obscures the image. So your layer mask is in some sense on top of the image that you have linked it to. 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. Easiest way is probably the paintbrush. Make sure your colors are set to white as the background and black as the foreground. Then select the paintbrush and paint something on the layer mask using your black color. So you can paint something on there. Now if you want to see the effect right click on the layer in the layer dialog and select apply layer mask and what you will see is that whatever you've painted is now taken out of the image and replaced with transparency which remember in GIMP that means the gray checkerboard pattern. Now the other thing you'll notice is that if you've used a brush that has fuzzy edges your transparency will have fuzzy edges. So there won't be a sharp border between transparency in the image. They'll be a little shading in between them. Yeah there's another way to achieve partial transparency and opacity and that is by painting with a shade of gray instead of pure black. As the gray gets darker there is more transparency. As the gray gets lighter there is more opacity. Now 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 0 0 0 0 0 0. These are all hexadecimal. White has the value of FF FF FF so it's basically an additive color thing. If you add all of the colors together the red, the green, and the blue at maximum you get pure white. A black is the absence of any of them. Now 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 that color by typing in new numbers. Now I did this and I did a fairly simple kind of modification using tutu tutu tutu which is near transparency and did a stripe across the just a painted a stripe across the top of the image. Then 44444 then 66666 and 88888. AAAAACCCCCC and EEEEEEE which is minimum transparency. So what I did then as I took the image and looking at the image mask I drew stripes across the mask with each of those colors so that I had minimum transparency in the middle shading to maximum transparency at the top and the bottom. There's nothing terribly artistic. It was just an illustration of how this thing works. So I drew these stripes freehand you know they're a little rough but you can see that 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. Now 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 so I did that with our flower image then I used the image of the ladies that we looked at previously and selected open as layers. This does two good things. First it opens it as a layer in the same gimp project I'm in with the flower image. If I had just used 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 just one less manipulation I need to do. 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. On the layer line the rectangle with the white border is the active one the rectangle with the black border is inactive. You can always figure out what's going on there. Now since the layer mask is already a white rectangle you're not going to see a 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 and I changed my foreground color to 888888 and then use bucket fill to apply this to the entire image. With this partial transparency I get an image of the ladies with the flower partly coming through the image. Now again this this was not a terribly lovely image that I created here but it's really just a way of illustrating how this process works. Now a note about non-destructive editing. Now 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 that it made it to the FAQ page so it is a frequently asked for enhancement. One will GIMP support any kind of non-destructive editing like adjustment layers layer filters and our full blown node based editing. The answer on the FAQ page 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 and I give a link in the show notes if you want to take a look at that. Now given that the current version of GIMP is 2.10 there is a 2.99 which is sort of a pre-release beta of version 3. So I'm guessing 3.2 is probably at least a few years off. Now 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 just delete that duplicate layer and still have your original. And you can do this many times along the way. It's kind of a manual form of version tracking that you can do if you're careful to do it. 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 the image. Now you could of course delete them I think it's better to keep everything. Your .xcf file is a working file that you can return to whenever you need to make changes to an image. So create lots of layers. Keep all of them in your .xcf file. If you get in the habit of doing this someday you will be very thankful. Now a little side note. Some years ago I was a college professor and one of the things I would tell my students because I was not just a college professor I was sort of the computer training person at the college. So I would try and train everyone. Save your work frequently when working on computers and I would show them how you can go into your word processing program and set it to automatically back up your file every so many minutes things like that. Some of them listened but you know one day I was in the computer lab which was kind of where I spent a lot of time when I was a professor. A young man was suddenly very upset. It turns out he had just finished his paper which was due the next morning and it 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 and so you know when I say keep duplicates, save your duplicates back up. You know there's a reason for it. Those are hard learned lessons in life. So this is a hook up for Hacker Public Radio signing off and as always encouraging you to support free software. Bye bye. You've been listening to Hacker Public Radio at Hacker Public Radio. We are a community podcast network that releases shows every weekday Monday through Friday. Today's show, like all our shows, was contributed by an HBR listener like yourself. If you ever thought of recording a podcast and click on our contributing to find out how easy it really is. Hacker Public Radio was founded by the digital dog pound and the infonomicon computer club and it's part of the binary revolution at binrev.com. If you have comments on today's show, please email the host directly, leave a comment on the website or record a follow-up episode yourself. Unless otherwise status, today's show is released on the creative comments, attribution, share a life, free.or license.