NOTICE: I have posted a new tutorial explaining the basics of layer masks. Check it out here.
Here is a way to use layer masks and the paths tool to merge parts of two photos into one composite image. We’ll start by taking two photos of a television, using a tripod to keep the position of the camera exactly the same. We won’t use a flash, so the first photo will have a slower shutter speed to get the correct exposure on everything around the TV. However, this makes the image showing on the TV way overexposed and blown out. So we’ll take a second photo with a much faster shutter speed to get the correct exposure on the screen.
We will use Gimp to put these two photos together. We’ll open both photos as layers. You can click on File -> Open as Layers, or you can press Ctrl-Alt-O. On the layers palette, we’ll name the two layers “screen” and “room.”
Even though I used a tripod, my two photos don’t line up exactly, so I’ll need to correct that.
I put the screen layer above the room layer and set it to a low opacity. Then I used the move tool to get it lined up correctly.
Now I reset the opacity on the screen layer to 100% and move that layer below the room layer.
Right-click on the top layer and choose “Add layer mask.” In the box that pops up, choose to fill it with White (full opacity). On the layers palette, you’ll see a small white box next to the thumbnail of the top layer, and it will have a white border around it to indicate that it is the part of the layer you are now working with.
Here is some information about layer masks, from the Gimp documentation:
A transparency mask can be added to each layer, it’s called Layer mask. A layer mask has the same size and same pixel number as the layer to which it is attached. Every pixel of the mask can then be coupled with a pixel at the same location in the layer. The mask is a set of pixels in gray-tone on a value scale from 0 to 255. The pixels with a value 0 are black and give a full transparency to the coupled pixel in the layer. The pixels with a value 255 are white and give a full opacity to the coupled pixel in the layer.
Use the paths tool to draw around the edges of the screen. My tutorial on how to use the paths tool can be found here. Make sure you get the path right along the edge of the screen. It doesn’t hurt to get some outside the screen, but you want to make sure the blown out image is completely within the path you’re drawing. Then in the tool dialogue, click the “Selection from path” button.
Choose the paint bucket tool and make sure the foreground color is black. Click once inside the selection border. This fills the selection with black. But because we’re working on the layer mask, it simply makes everything on that layer, in that selection, invisible. So the image on the layer below now becomes visible through the “hole” we created in the layer mask above it.
Now we can flatten our image under the Image menu, and there we have our composite image with the correct exposure for both the TV screen and the areas around it.










how does this translate to Photoshop?? I am not familiar with Gimp but is the process similar in CS2?
Thanks,
Alex
I haven’t used Photoshop in a long time but, from what I remember, I think the steps would be very similar.
Thanks! I wasn’t really look for this but it showed me something I would not have known if I hadn’t seen this. Thanks!
Glad I could help
Thanks, this helps me understand how layer mask works.I was having trouble with the mask tool.
Thanks for commenting.
Thanks for the tutorial, I’m new to GIMP, so please forgive me if I’m asking stupid questions.
Why is it necessary to create a layer mask to the layer? Will I achieve the same result by just doing the path selection and delete the inside area on the main layer so that the second layer underneath can be visible?
Thanks!!
Yes, you could do that and it would work fine. One point of using a layer mask is to preserve the part of the image that you’re masking, in case you want to change it later. One of the great things about GIMP is that there is always more than one way to do something. Thanks for leaving a comment.
Very helpful in making me understand the concept of layer masking. Thanks much.
I love you for making Firefly your example
I was wondering, is there any way to apply layer masks to animated GIFs? Like, keeping the background layer visible but only making a section of the animated GIF, well, animated? Might be a bit of a big question.
I think tutorial might be helpful to you:
http://bavatuesdays.com/isolating-animation-with-masked-layers-in-gimp/
+1 Bazillion points for changing the image on the screen to Serenity. FireFly FTW!
Why would you use one of the most complicated things you could think of – initializing TWO files and merging them – in a TUTORIAL??? Ridiculous. How about just getting the layers to SHOW UP and work with BASICS?
Thanks for posting this tutorial. I was looking to take the GIMP to the next level, and this is a great introduction to working with masks.
Finally I get layer masks
Thanks!
Very good. The tutorial is in simple clear English. Not all ‘experts’ in GIMP (such as those who wrote the GIMP Bible) have the ability to explain things in simple straightforward language. Reading about layer masks in the “Bible” left me confused; this tutorial leaves me with immediately useful and clear knowledge! Much appreciated.
Thanks, Kamjori!