You can use Photoshop for years and never use a mask—but you’ll get a lot more done if you learn how to create and apply masks. Painting or cloning next to an object you don’t want to change? Be sure to mask the object so you won’t accidentally paint over it, just the way you mask woodwork when you’re painting a wall. Changing the color of the sky? Mask the rest of the image so you don’t turn it pink. You can use selections as temporary masks; any time a selection is active, you can paint or apply filters and adjustments only within its bounds. Selections are easy to accidentally drop, however, so Photoshop provides you with other kinds of masks that stay active while you do other things, until you specifically delete or hide them. These semipermanent masks include vector- and pixel-based layer masks.
You can use layer masks to hide things that you’re not entirely sure you want to delete from the image; you might need them for another version of the design, or you might change your mind about hiding them later. Layer masks can also give a particular shape or type of edge to an image without actually deleting the parts of the image outside that shape.
Masks show up in a couple different places within Photoshop: the Layers panel (layer masks and clipping masks) and the Channels panel (alpha channels made from saved selections and Quick Masks). Layer masks—including those for adjustment layers, shape layers, and fill layers—also show up in the Channels panel whenever their layer is the active layer. There’s even a kind of mask that you can’t see anywhere: transparency masks. Every transparent layer has one of these, and you can convert it into a selection by Command-clicking (Mac) or Ctrl+clicking (Windows) the layer’s thumbnail in the Layers panel.
With all these kinds of masks, how are you supposed to learn how to work with them all, much less which kind to use for what? Relax; that’s what we’re doing in this hour. Just follow along, and I promise you’ll be a mask expert by the end of the hour.
First, let’s take a look at what masks are and, in general, how you use them. Masks can hide either a selected object or the background around that object, and they can be opaque, semitransparent, or even completely transparent, although a completely transparent mask doesn’t mask anything. Most masks—and channels, which you’ll learn about later—are actually grayscale images. Opaque areas of a mask are black, 50% transparent areas are 50% gray, and transparent areas are white.
In Figure 12.1, I have a nice photo shot in Arizona that somehow managed to capture a cloudy sky. (I know, I didn’t think they had clouds in Arizona, either.) To my eye, this picture would be a lot more interesting if I could do something with that boring white sky. The rest of the image is accurate for color, as nearly as I can remember, so I don’t want to change it. If I select just the sky, I can work on it without affecting the rest of the photo.
Creating a selection like this is the most basic kind of masking. It’s not always perfect, though. In Figure 12.2, you can see that making a selection using the Quick Selection tool didn’t really give me an accurate mask. The edges aren’t very smooth, and some of the bluish hills in the distance are included in the selection with the sky. I’m definitely going to need a way to edit this selection—and it’s called Quick Mask.
Photoshop provides a quick and easy way to make a temporary mask that can be edited: Quick Mask. One of its advantages over working with selections is that you can see both the image and the mask, including partially masked areas, at the same time. You can start with a selection such as the one in Figure 12.2 and use the Painting tools to add to or take away from it, or you can create the mask from scratch entirely in Quick Mask mode. Let’s apply a Quick Mask to an image.
If you think you might need to use the same mask again, you can save it after you’ve returned to Standard mode by clicking the Save Selection as Channel button at the bottom of the Channels panel. (It looks just like the Quick Mask button.) This saves your mask as an alpha channel; you can take a look at it by clicking its thumbnail in the Channels panel. Now you can turn that channel back into a selection any time you want by Command-clicking (Mac) or Ctrl-clicking (Windows) the channel’s thumbnail in the panel.
A layer mask hides and reveals parts of a single layer without deleting any of that layer’s contents. Layer masks, like Quick Masks, can be edited; unlike Quick Masks, however, they don’t prevent you from editing the area they mask—just from seeing it. If you don’t like the result, simply discard the mask, and your image is left untouched. If you do like what you see, you can just leave the mask in place or apply the mask to make the changes permanent. Most of the time, you’ll create and edit pixel-based layer masks. But if you like working with the Path and Shape tools, Photoshop now lets you use those tools to create vector-based layer masks. You’ll learn how to create both kinds of layer masks in this section.
You can’t add a layer mask to the Background layer. If the part of the image that you want to mask is on the Background layer, double-click the Background layer in the Layers panel and rename it to turn it into a regular layer. Then you’ll be able to mask that layer.
Clipping masks enable you to mask the contents of one layer with the shape of another layer. For example, you might mask an image, gradient, or pattern layer with a type layer to give the effect of type filled with an image while maintaining the type as editable text (see Figure 12.6).
To apply a clipping mask, first you have to correctly position the layers involved. You can use as many layers as you want; they’ll all be masked by the one layer at the bottom of the stack. Together, the mask layer and the layers it’s masking are referred to as a clipping group.
In the case of my type example, you’d start by moving the type layer below any layers that you want it to mask. Then Option-click (Mac) or Alt-click (Windows) the line between the type layer and the layer immediately above it in the Layers panel. To add more layers to the clipping mask, just drag them so they’re adjacent to the upper layer in the clipping group and Option-click or Alt-click again between the two layers.
You can use any layer you want as a clipping mask. The contents of the mask layer won’t be visible—only its shape will. Transparent parts of the mask layer hide corresponding areas of the other layers in the clipping group, while opaque areas enable the other layers’ contents to show through.
To make a pixel-based layer mask, select an area of the image to mask and click the Add Layer Mask button (the second button from the left) at the bottom of the Layers panel. When you do, you see a layer mask thumbnail next to the layer’s image thumbnail (see Figure 12.7). In the thumbnail, black indicates the portions of the layer that are hidden and white shows the parts that are revealed. If the mask were made to be semitransparent, the partially masked areas would be shown in gray. This happens if you turn a feathered selection into a layer mask, for example.
Creating a vector-based layer mask works slightly differently. Instead of creating a selection, you start by drawing a path. You can use the Pen tool or any of the Shape tools; either way, you need to make sure that the Paths button at the left end of the Options bar is active instead of Shape Layers or Fill Pixels. When your path or shape is complete, choose Layer, Vector Mask, Current Path to convert it into a layer mask. Not surprisingly, the mask thumbnail in the Layers panel looks just like the thumbnail for a shape layer. By default, vector masks either hide completely or show completely; there are no partially transparent pixels in a vector mask.
Whether you’re working with a pixel mask or a vector mask, you’ll see links between the two thumbnails in the Layers panel, indicating that the mask is linked to the layer. After you create the mask, you can edit it by clicking the mask icon. For a pixel-based layer mask, the Foreground and Background colors revert to the defaults. You can then paint with black to add to the mask or with white to remove parts of it. To edit a vector mask, switch to one of the Path tools and modify the path. (I show you how to work with paths in the next hour.)
If you create your mask using the Layer menu, you can choose whether the selected area will be shown (and the rest of the image masked) or masked (and the rest of the image shown). Choose Layer, Layer Mask, and choose either Hide Selection or Reveal Selection, depending on whether you want to mask the area around the selected piece of image or the image itself. Figure 12.8 shows the menu for pixel-based layer masks; the commands for vector masks are immediately below these in the Layer menu.
Hide Selection hides the area that you have selected so you can work on the rest of the image. You can re-create the selection from this mask at any time by Command-clicking (Mac) or Ctrl+clicking (Windows) the mask’s thumbnail in the Layers panel; that protects the unselected part of the picture while you work on the rest. The Reveal Selection, as you might imagine, does just the opposite of Hide Selection. This command hides everything on a layer except that area within the Marquee selection. The other commands, Hide All and Reveal All, work a little differently. As their names suggest, these commands create masks that are entirely opaque or entirely transparent across the entire layer.
In Figure 12.9, I’ve masked the beach and water and then scribbled across the entire picture. The writing is visible only in the unmasked area.
Each layer can have only one layer mask of each type. If you need to do additional temporary masking on a layer that already has a pixel-based mask, activate the layer and use Quick Mask (press Q).
Take some time now to open an image and practice applying masks. Try working with Quick Mask first, and then make a selection and turn it into a layer mask. If you practice these skills while they’re fresh in your mind, you’ll remember them later when you need to do a quick color change or preserve an object while swapping out its background.
Photoshop CS4 comes with a brand-new Masks panel designed to make it easier for you to select and modify masks (see Figure 12.10). Here’s a brief tour of the new panel:
In the top-right corner of the panel, you’ll see two Select/Add buttons, one for pixel masks and the other for vector masks. If the current layer doesn’t have either type of layer mask, clicking one of these buttons adds the corresponding mask. If the layer is already masked, clicking a button selects the corresponding mask so you can edit it.
Below that is a Density slider. This value works just like a layer’s Opacity value; lowering it from 100% allows the masked layer to show through somewhat.
Next comes a Feather slider. Drag this to blur the appearance of the mask’s edges without actually modifying it. You can go back and change this value as many times as you want until you’re happy with the mask’s appearance.
In the Masks panel’s Refine area, you’ll find three buttons. The first, Mask Edge, opens a dialog that’s identical to the Refine Selection Edge dialog you learned about in Hour 3, “Making Selections.” Use the controls in this dialog to expand, shrink, or soften a pixel-based mask’s edges; none of the Refine controls works for vector masks. Under that is the Color Range button, which opens another familiar dialog: the Color Range dialog, which was also featured in Hour 3. Here you can modify the mask by adding or removing areas based on their colors. Finally, you can click the Invert button to turn the mask’s black areas white and its white areas black.
Along the bottom edge of the Masks panel are four more buttons: Load Selection from Mask, which creates a new selection based on the mask; Apply Mask, which deletes the mask and makes its effects permanent; Disable/Enable Mask, which temporarily hides the mask and shows it again; and Delete Mask—I’ll leave it to your imagination what that last one does.
To target a layer mask so that you can modify it, either click its thumbnail in the Layers panel to make it active, or click the layer itself and then click the appropriate button in the Masks panel to select the mask you want. If you’re working in the Layers panel, when a mask is active, you’ll see the thumbnail outline move from the layer thumbnail to the mask thumbnail. This lets you know that any edits you perform will be applied to the mask instead of the layer content.
If you’re working with a pixel-based mask, you can Option-click (Mac) or Alt+click (Windows) the mask’s thumbnail in the Layers panel to display just the mask in the image window, hiding the layer’s contents. Choose a Painting tool and paint the mask with black to add to the mask, with white to subtract from the mask, or with gray to make the layer partially visible. As you work, the mask thumbnail (either in the Masks panel or in the Layers panel) displays your changes. Figure 12.11 shows a mask being edited.
To edit a vector mask, activate it the same way, by clicking its thumbnail in the Layers panel or clicking the Select Vector Mask button in the Masks panel. Instead of painting or erasing to make changes, you can modify the path itself using the Path tools. In the next hour, you’ll learn how to use these tools to add and delete corner points, modify curves, and move line segments.
To go back to editing the layer instead of its masks, click its thumbnail in the Layers panel. In addition to clicking the Disable/Enable button in the Masks panel, you can turn off the layer mask by choosing Layer, Disable Layer Mask, or by Shift-clicking the mask’s thumbnail in the Layers panel. When you’ve disabled the mask, Photoshop puts a large red X through the mask thumbnail so that you know it’s inactive (see Figure 12.12). You can still paint on a mask while it’s inactive, though, so be careful!
When you’re done with a layer mask or you want to start over, you can get rid of it in two ways. The first way, and the easiest, is simply to drag the layer mask’s thumbnail onto the Delete button (which looks like a trash can) at the bottom of the Layers panel. You also can get rid of a layer mask by choosing Layer, Layer Mask, Delete, or Layer, Layer Mask, Apply (see Figure 12.13); or, if it’s a vector mask, choose Layer, Vector Mask, Delete. If you drag the mask to the trash, you are presented with the dialog shown in Figure 12.14, in which you are prompted to apply the effects of the mask or discard the mask without applying it.
Each mask that you add to an image creates a new channel in your image, called an alpha channel. You can see all these channels in the Channels panel. Channels are Photoshop’s way of storing both color and mask information. If you add a mask to a layer and choose Window, Channels, you’ll see something like the example in Figure 12.15.
Click the eye icon to the left of an alpha channel in the Channels panel; the mask appears in the image window as red, representing a transparent red plastic film called rubylith (a carryover from the old days when this stuff was done with paper, glue, and X-Acto knives in the real world). You can also target the mask for editing in the Channels panel. More important, you can save it by choosing Duplicate Channel from the panel menu. You’ll get a dialog like the one in Figure 12.16, letting you save the mask either as part of the document or as its own document. To turn a selection into an alpha channel, choose Select, Save Selection, or click the Save Selection as Channel button at the bottom of the Channels panel. It’s another quick and easy way to make a mask.
In this hour, you looked at using masks. Masking enables you to apply changes selectively, while protecting parts of the picture that you don’t want to change, or to hide parts of an image without deleting them. You learned about modifying selections using Quick Mask mode and how to edit a mask with the Brush and Eraser. Then you learned about layer masks, both pixel-based and vector-based. You learned how to view your mask and how to save it as an alpha channel.
Find a picture with several similar objects in it. Mask them separately and experiment with changing the colors of the objects, one at a time, without changing the background. Try using both vector- and pixel-based layer masks. You’ll find that vector masks are great for masking geometric objects, whereas pixel masks work better for complex objects and soft-edged selections.