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.