Layer masks let you hide or reveal parts of a layer without deleting pixels. Think of a mask as a grayscale “visibility map” attached to a layer: white areas show the layer, black areas hide it, and gray areas partially show it. Because you edit the mask (not the layer’s pixels), you can revise blends later, swap backgrounds, and fix edges without starting over.
How a Layer Mask Works (White, Black, Gray)
- White on the mask = the layer is fully visible in that area.
- Black on the mask = the layer is fully hidden in that area (you see layers below).
- Gray on the mask = partial transparency (soft blending).
Most mask work is simply painting with black/white (and sometimes gray) on the mask using a brush, gradient, or fill.
Adding a Layer Mask (Different Starting Points)
To add a mask: Right-click the layer in the Layers panel → Add Layer Mask…. You’ll choose how the mask starts:
| Mask option | What it does | When to use |
|---|---|---|
White (full opacity) | Everything on the layer starts visible. | You want to hide parts by painting black. |
Black (full transparency) | Everything starts hidden. | You want to reveal only certain areas by painting white. |
Selection | Uses an active selection to define visible/hidden areas. | You already have a rough cutout and want it as a starting mask. |
Grayscale copy of layer | Creates a mask based on the layer’s luminance. | Advanced: useful for blending based on brightness. |
Quick mental model
If you’re bringing in a new sky behind a subject, you’ll often add a mask to the foreground/subject layer (white mask) and paint black where you want the sky to show through.
Editing the Mask: Paint, Fill, Invert
1) Make sure you’re painting on the mask (not the layer)
In the Layers panel, a masked layer shows two thumbnails: the layer thumbnail and the mask thumbnail. Click the mask thumbnail to target it. A border highlight indicates which one is active.
- Listen to the audio with the screen off.
- Earn a certificate upon completion.
- Over 5000 courses for you to explore!
Download the app
2) Paint on the mask
- Choose the Brush tool.
- Set your foreground color to black to hide, white to reveal.
- Paint on the image while the mask thumbnail is active.
Tip: If you “erase” and nothing seems to happen, you’re likely painting on the layer instead of the mask, or your brush opacity is too low.
3) Fill large areas quickly
For big regions, use the Bucket Fill tool on the mask (black to hide, white to reveal). This is faster than brushing large flat areas.
4) Invert a mask (swap hide/reveal)
To flip what’s visible: click the mask thumbnail → Colors → Invert. White becomes black and vice versa. This is useful if you started with the opposite mask type or want to reverse your approach.
Viewing and Debugging: Mask vs Layer
When edges look wrong, inspect the mask directly.
- View mask only:
Alt-click the mask thumbnail (Option-click on macOS). The canvas shows the mask in black/white/gray. - Back to normal view: Alt/Option-click the mask thumbnail again.
- Temporarily disable the mask: Shift-click the mask thumbnail. A red X appears over it. Shift-click again to re-enable.
- Show mask overlay (if available in your setup): some workflows use a quick mask-like overlay; if you don’t see it, rely on Alt/Option-click and toggling visibility.
Mask-only view makes it easy to spot accidental gray smudges, jagged transitions, or missed holes.
Soft Transitions: Brush Hardness, Opacity, and Build-Up
Seamless composites rarely use a 100% hard edge. Soft transitions come from controlling how quickly the mask changes from white to black.
Brush hardness
- Hard brush creates a sharp mask edge (good for crisp objects like product shots, buildings, or graphic elements).
- Soft brush feathers the edge (good for hair, foliage, haze, depth-of-field areas).
Opacity and gradual strokes
Lower brush opacity lets you “sneak up” on the blend. Instead of one heavy stroke, use multiple light strokes to build a natural transition.
- Try 20–40% opacity for refining edges.
- Use a larger soft brush for broad blending, then a smaller brush for detail.
Practical example: controlled edge refinement
If the subject edge looks too cut-out, paint with black at low opacity on the mask along the edge to let a little of the background show through. If you remove too much, switch to white and paint it back.
Smooth Blends with Gradients (Perfect for Skies)
Gradients create a clean, even transition that’s hard to achieve by hand. They’re ideal when the change should be gradual (horizon haze, depth fade, fog, or a sky that should blend behind distant objects).
How to apply a gradient to a mask
- Click the mask thumbnail to target the mask.
- Select the Blend (Gradient) tool.
- Set the gradient to
FG to BG (RGB)with black/white as your foreground/background colors. - Drag on the canvas: the drag direction controls where the mask transitions from white to black.
Short drags create a faster transition; long drags create a smoother, more gradual blend.
Structured Practice: Replace a Sky/Background Using a Mask
This practice focuses on controlled blending, edge refinement around hair/clutter, and fixing halos.
Goal
Composite a new sky (or background) behind a subject while keeping edges natural—especially around messy details like hair, tree branches, or fence lines.
Setup
- Open your subject photo (foreground).
- Open the replacement sky/background as another layer and place it below the subject layer.
- Ensure the sky layer covers the full canvas (scale/position as needed).
Step 1: Add a mask to the subject layer
- Right-click the subject layer →
Add Layer Mask… - Choose
White (full opacity)→Add
Now the subject is fully visible, and you’ll hide the old sky by painting black on the mask.
Step 2: Hide the old sky with broad strokes
- Click the mask thumbnail.
- Choose a large soft brush (low hardness).
- Set color to black, opacity around 60–100% for big areas.
- Paint over the old sky/background area to reveal the new sky layer underneath.
Don’t worry about perfect edges yet—get the overall replacement working first.
Step 3: Refine edges around hair/clutter with gradual brush strokes
- Zoom in near hair, foliage, or busy edges.
- Reduce brush size and lower opacity to 20–40%.
- Paint with black on the mask to let the new background show through tiny gaps.
- If you remove too much of the subject, switch to white and paint back gently.
Use repeated light strokes rather than one heavy stroke. This creates a more believable mix of foreground detail and background.
Step 4: Use a gradient for natural sky falloff (optional but powerful)
If the transition should be smoother near the horizon or behind distant objects:
- On the mask, use the Gradient tool with black-to-white.
- Drag a long gradient where you want a gentle blend (for example, near the horizon line or behind thin branches).
If the gradient affects too much, undo and drag a shorter gradient, or limit the gradient to a smaller area by painting white/black afterward.
Troubleshooting Halos and “Cut-Out” Edges (Mask Cleanup)
Halos usually appear as a light or dark outline around the subject after replacing the background. They often come from leftover pixels of the original background or from an edge that’s too sharp/too soft in the wrong way.
Checklist: diagnose the problem first
- Light halo on dark new background: old bright sky is still partially visible at the edge.
- Dark halo on bright new background: edge is hiding too much, or the mask transition is too aggressive.
- Crunchy edge: brush hardness too high or mask edge too jagged.
- Muddy edge: too much gray on the mask; transition is overly wide.
Technique 1: Inspect the mask directly
- Alt/Option-click the mask thumbnail to view it.
- Look for unintended gray fringes or speckled areas along the edge.
- Paint with white to restore solid subject areas, or black to remove leftover background.
Technique 2: Tighten the mask edge with a controlled pass
This is a simple, reliable cleanup method:
- Target the mask thumbnail.
- Use a small soft brush at 20–30% opacity.
- Paint black just outside the subject edge to remove bright fringes.
- Paint white just inside the subject edge if you accidentally ate into the subject.
Work slowly and alternate black/white as needed. The goal is a clean edge with a narrow, natural transition—not a thick gray band.
Technique 3: Slight blur on the mask (use sparingly)
If the edge is too jagged, a tiny blur on the mask can help:
- Alt/Option-click the mask thumbnail to confirm you’re working on the mask.
- Apply a small blur:
Filters → Blur → Gaussian Blurwith a very low radius. - Return to normal view and check the composite.
If the edge becomes too soft, undo and instead use a softer brush with lower opacity for manual refinement.
Technique 4: Remove pinholes and specks
Busy areas (hair, leaves, fences) can leave tiny holes or leftover dots.
- In mask-only view, use a small brush to fill pinholes (paint white) or remove specks (paint black).
- For repeated tiny defects, a slightly larger soft brush at low opacity can “average out” the edge without obvious brush marks.
Technique 5: If you masked the wrong thing, invert instead of restarting
If you realize you hid the subject instead of the background (or vice versa), invert the mask: click mask thumbnail → Colors → Invert, then continue refining.