Master the layer mask in Photoshop

This document presents the Layer Mask of Photoshop: its principle, its use with the Gradient Tool and the Brush Tool, then the stacking of several layer masks with layer groups.

A layer mask hides or reveals areas of a layer, which lets the layer below show through. It works like a stencil that you edit with the Brush Tool or the Gradient Tool.

A layer mask contains only white, black and shades of gray: white displays the pixels of the layer, black hides them, and a gray gradient makes the layer below appear gradually.

A layer mask is non-destructive: the image of the layer it is applied to stays intact.

Catalog reference: Photoshop Tutorial_0014.

Identify the level of each chapter

🟢 All levels

  • Core concepts to master.
  • Recommended for all users.

🟡 Intermediate level

  • Requires mastery of the core concepts.
  • Commonly used techniques.

🔴 Expert level

  • Advanced techniques.
  • Used in specific or professional cases.

🟢 Apply a gradient to a layer mask

For all Photoshop projects, it is recommended to always create a copy of the base Background layer and hide the original layer. This method preserves the original image: if you are not satisfied, delete the copy and create a new one.

Duplicate the Background layer [Windows shortcut: Ctrl + J] [Mac shortcut: Cmd + J], then hide the original layer by clicking the eye icon to its left.

Create a new empty layer by clicking the Create a new layer icon (marker 1) at the bottom of the Layers panel. Check that this layer is visible with the eye icon next to the layer (marker 2). Drag it below the copy of the base layer.

Create an empty layer below the Background copy layer in the Layers panel

Select the Eyedropper Tool (marker 1) [Windows shortcut: I] [Mac shortcut: I], then sample the green of the car body by clicking the body. In this example, click the location of marker 2. The sampled color immediately becomes the foreground color and appears in the color squares at the bottom of the toolbar.

Sample the green of the car body with the Eyedropper Tool

Select the Layer 1 layer (marker 1) and hide the Background copy layer (marker 2). Select the Paint Bucket Tool (marker 3), choose the green color (marker 4), then click in the image to fill the whole Layer 1 layer with green.

Fill Layer 1 with green using the Paint Bucket Tool

Display the Background copy layer again by clicking the eye icon.

Display the Background copy layer again above the green layer

Select the Background copy layer (marker 1), then click the Add Layer Mask icon (marker 2) at the bottom of the Layers panel.

Click the Add Layer Mask icon of the Background copy layer

In the toolbar, click the small arrow at the bottom right of the Paint Bucket Tool, then select the Gradient Tool.

Choose the Gradient Tool under the Paint Bucket Tool

A layer mask works only with white, black or gray pixels. To obtain a gradient from black to white, click the Default Foreground and Background Colors icon (marker 1) [Windows shortcut: D] [Mac shortcut: D]. Check that the black and white gradient is displayed in the gradient preview of the options bar (marker 2), then select the Linear Gradient mode (marker 3).

Reset the colors and choose a black and white linear gradient in the options bar

Click the thumbnail of the layer mask to select it.

Locate the layer mask thumbnail linked to the Background copy layer

Check that the layer mask is selected: a frame appears around its thumbnail.

Check the frame around the thumbnail of the selected layer mask

Click at the bottom of the image, at the location of the blue dot, then hold down the mouse button and move up toward the center of the image, to the tip of the orange arrow. Then release the mouse button.

Draw the gradient on the mask from the bottom toward the center of the image

The gradient is applied to the layer mask: the green Layer 1 layer, located just below in the layer order, appears gradually.

Obtain the green layer appearing gradually at the bottom of the image

To better understand how the layer mask works, hide the Layer 1 layer (marker 1). The transparency of the gradient applied to the mask becomes visible (marker 2).

Hide Layer 1 to view the transparency created by the gradient

To check that the layer mask is non-destructive, right-click its thumbnail, then choose Disable Layer Mask. The mask is temporarily inactive and the original image is not affected by the changes made on the mask.

Disable the layer mask to recover the intact original image

To continue exploring the layer mask, select the Brush Tool [Windows shortcut: B] [Mac shortcut: B] and the black color, to remove pixels on the layer mask.

Select the Brush Tool with black as the foreground color

Apply the brush to the top of the image. In the illustration below, the pixels are removed from the layer mask, which acts as a stencil, and reveal the green pixels of the Layer 1 layer located directly below.

Paint in black on the mask to reveal green at the top

Then select the Brush Tool with the white color to restore the pixels and “fill in the holes”.

Select the white color and the Brush Tool in the toolbar

In the lower part of the illustration below, using white with the brush on the layer mask restores the original pixels of the layer.

Restore the original pixels by painting in white on the mask

The changes made on the layer mask appear on the thumbnail of the mask.

Observe the brush marks on the layer mask thumbnail

🟢 Use the brush on a layer mask

The exercise consists in keeping the sandy beach of the image on the left and adding to it the purple sky and sea of the image on the right.

Compare the beach photo on the left and the purple photo on the right

To start, duplicate the base layer to make a copy that serves as the working base for editing the images: right-click the thumbnail of the Background layer, then choose Duplicate Layer….

Duplicate the Background layer with the Duplicate Layer command

Import the second image into Photoshop by dragging and dropping it.

Import the second image into the Photoshop document by drag and drop

Press the Enter key: the imported image is converted into a Smart Object. This type of layer lets you resize the image without degrading its pixels. The symbol at the bottom right of the layer thumbnail shows that it is a smart object.

Locate the Smart Object symbol on the thumbnail of the imported layer

Resize the image placed at the top of the layer stack with the Free Transform command [Windows shortcut: Ctrl + T] [Mac shortcut: Cmd + T], so that it covers the image placed below.

Resize the top image with Free Transform

Decrease the Opacity value of the layer placed at the top of the stack so that the image below begins to show through.

Reduce the opacity of the top layer to let the image below show through

Select the Move Tool (marker 1) [Windows shortcut: V] [Mac shortcut: V], then move the image with the arrow keys of the keyboard so that the two horizons (markers 2 and 3) overlap.

Select the Move Tool to align the two horizons

Use the arrow keys of the keyboard to move the image

In the illustration below, the two horizons overlap.

Overlap the two horizons after moving the image

Set the Opacity value of the purple layer back to 100% to make it fully opaque.

Restore the opacity of the purple layer to 100%

In the Layers panel, swap the order of the layers by dragging and dropping, as shown below.

Swap the order of the layers by drag and drop in the Layers panel

Select the top layer, then click the Add Layer Mask icon.

Create a layer mask on the top layer Background copy

Select the layer mask that was just created.

Select the layer mask that was just created

Select the Brush Tool.

Select the Brush Tool in the toolbar

In the tool settings, choose a brush size suited to the size of the image and a suitable hardness. In this example, enter 500 px in the Size field and 54% in the Hardness field.

Set the brush size to 500 px and the Hardness to 54%

Select the white color.

Choose the white color in the Color Picker

Start applying the brush on the layer mask.

Start applying the brush on the layer mask

The photo placed on the lower layer begins to appear.

Observe the photo of the lower layer beginning to appear

In the illustration below, the final result shows that the beach of the photo placed on the upper layer is kept, while the sky and the sea of the photo placed on the lower layer appear thanks to the layer mask.

Obtain the preserved beach with the purple sky and sea

🟡 Stack layer masks

This chapter builds on the example of the first chapter, in which the Gradient Tool is used on the layer mask to reveal the green layer placed just below. It presents the method to apply the same treatment to the four sides of the image, to illustrate the technique of stacking layer masks.

In the illustration below, a gradient is already applied to the lower part of the image through the layer mask.

Start from the image whose lower part is already treated with a gradient

Select the Background copy layer, then click the Create a new group icon at the bottom of the Layers panel.

Click the group creation icon of the Layers panel

Drag the Background copy layer into Group 1.

Drag the Background copy layer into Group 1

In the illustration below, the thumbnail of the Background copy layer shifts to the right when it is placed in Group 1.

Notice the Background copy layer shifted to the right in Group 1

Select Group 1 (marker 1), then click the Add Layer Mask icon (marker 2) to create a layer mask.

Select Group 1, then click Add Layer Mask

A layer mask is created at the level of Group 1. Select it: a frame appears around its thumbnail when it is selected.

Locate the frame around the new layer mask of Group 1

Select the Gradient Tool in the toolbar, with the same settings as in the first chapter (black and white gradient, Linear Gradient mode).

Select the Gradient Tool in the toolbar again

Apply a gradient from top to bottom on the upper part of the image, through the layer mask of Group 1.

Obtain the top-to-bottom gradient thanks to the mask of Group 1

Click the Create a new group icon again. Photoshop automatically names this new group Group 2.

Create Group 2 above Group 1 in the Layers panel

Drag Group 1 into Group 2. In the illustration below, the thumbnail of Group 1, which contains the Background copy layer, shifts to the right in the Layers panel.

Drag Group 1 into Group 2, whose thumbnail shifts to the right

Select Group 2, then create a layer mask as for Group 1.

Create a layer mask on Group 2

Apply a gradient from left to right on the left part of the image, through the layer mask of Group 2.

Obtain the left-to-right gradient thanks to the mask of Group 2

Click the Create a new group icon again. Photoshop automatically names this new group Group 3.

Create Group 3 above Group 2 in the Layers panel

Drag Group 2 into Group 3.

Drag Group 2 into Group 3

Select Group 3, then create a layer mask as for Group 1.

Create a layer mask on Group 3

Apply a gradient from right to left on the right part of the image, through the layer mask of Group 3.

Obtain the right-to-left gradient thanks to the mask of Group 3

In the illustration below, the layers and groups are organized this way at the end of the project.

Observe the final organization of the layers and groups at the end of the project