How To Auto-Align And Composite Images In Photoshop

How To Auto-Align And Composite Images In Photoshop

Written by Steve Patterson.

How many times have you found yourself trying to choose between two similar photos of your subject where neither photo is perfect? It's a common problem with group shots where in one photo, someone's eyes are closed, and in the other, someone else is looking in the wrong direction.

Wouldn't it be great if, rather than being forced to choose between them, there was an easy way to merge the two images together, keeping only the best elements from each photo, to create that elusive, perfect shot? Fortunately, there is!

In this tutorial, we'll learn how to easily align and composite images in Photoshop. In fact, you may be surprised by just how easy it is to do since we're going to let Photoshop do much of the work for us. First, we'll use a command few people know about to automatically load our photos into the same document and place each one on its own independent layer. Then, we'll align the images using Photoshop's powerful Auto-Align Layers command. Finally, we'll use a layer mask to hide the unwanted areas in one photo and replace them with the better versions from the other photo!

I'll be using Photoshop CC here but this tutorial is also fully compatible with Photoshop CS6.

Here's the two photos I'll be working with, taken one sunny afternoon while driving around the countryside. In this first image, I like the horse on the right as it approaches and looks straight into the camera, but the horse on the left is looking down and showing me nothing but the top of its head:

A photo of two horses, with the horse on the left looking away. Image © 2015 Steve Patterson, Photoshop Essentials.com
The first image.

This second photo, taken a few seconds earlier, gives me a better view of the horse on the left, but the horse on the right is further back in the frame and not as interesting as it was in the first shot:

A second photo of the same horses, with a better view of the horse on the left.
The second image.

What I'd like to do is combine the best elements from both versions, taking the horse on the right from the first photo and merging it with the horse on the left in the second photo. Here's what the final composite version will look like:

A second photo of the same horses, with a better view of the horse on the left.
The final composite.

You can use the same steps we're about to learn to align and merge all kinds of images, from family and group shots to animals and pets, landscape and nature photos, or whatever the case may be, so feel free to follow along with your own images. Let's get started!

Step 1: Load Both Images Into The Same Document

Before we can align and merge our photos, we first need a way to get them both into the same document, with each image on its own separate layer. There's actually an easy way to do this, but few people know about it. Simply go up to the File menu in the Menu Bar along the top of the screen, choose Scripts, and then choose Load Files into Stack:

Selecting the Load Files into Stack script under the File menu. Image © 2015 Photoshop Essentials.com
Going to File > Scripts > Load Files into Stack.

If "Load Files into Stack" sounds confusing (which it does), think of it instead as "Load Files into Layers" because that's exactly what the script does; it opens two or more images into the same document and places each image on its own layer. In fact, there's a command in Adobe Bridge named "Load Files into Photoshop Layers" that does the same thing, but for this tutorial, we'll stick with Photoshop.

Once you've selected the script, Photoshop will pop open the Load Layers dialog box. This is where we tell Photoshop which images to open. Click the Browse button:

Clicking the Browse button in the Load Layers dialog box.
Clicking the Browse button in the Load Layers dialog box.

Navigate to the folder on your hard drive where the images you want to merge are located. In my case, both of my photos are in a folder on my Desktop. I'll click on the first image to select it, then I'll press and hold my Shift key and click on the second image. This selects both images at once. With both of your photos selected, click the Open button:

Selecting both images and clicking Open.
Shift-clicking on the images to select them both, then clicking Open.

You'll see your selected images listed in the center of the Load Layers dialog box. Click OK to load them into Photoshop:

Selecting both images and clicking Open.
Clicking OK to load the selected images.

It may take a few moments, but both images will be loaded into the same document, each on its own layer. Since the photos are sitting one above the other, we can only see one of them at a time in the main document area:

Both images were loaded, but only one is currently visible.
Both images were loaded, but only one is currently visible.

If we look in the Layers panel, though, we see that, sure enough, both photos are there. The one on the top layer is the one currently visible in the document, but if you click on its visibility icon to the left of the layer, you'll temporarily turn it off, revealing the other image below it:

The Layers panel showing both photos loaded into the document.
Clicking the top image's visibility icon to turn it off.

With the top layer turned off, the image on the bottom layer is now visible in the document. Click the same visibility icon again to turn the top image back on:

Turning off the top layer reveals the photo on the bottom layer.
Turning off the top layer reveals the photo on the bottom layer.

Learn all about layers in Photoshop!

Step 2: Select Both Layers

In a moment, we're going to align the images, but to do that, we first need to have both layers selected. Click on the top layer in the Layers panel to select it if it isn't selected already. Then, press and hold your Shift key and click on the bottom layer. This will select both layers at once:

The Selecting both layers at once in the Layers panel.
Clicking the top layer, then Shift-clicking the bottom layer to select them both.

Step 3: Auto-Align The Layers

With both layers selected, go up to the Edit menu at the top of the screen and choose Auto-Align Layers:

Choosing the Auto-Align Layers command from under the Edit menu.
Going to Edit > Auto-Align Layers.

This opens the Auto-Align Layers dialog box. Photoshop is quite capable of doing an amazing job when aligning images, so we'll let it do all the work. Leave the Projection option at the top set to Auto (the default setting), then click OK:

Leaving the Projection option set to Auto in the Auto-Align Layers dialog box.
The default "Auto" option is all you need.

Again, it may take a few moments, but when it's done, your photos should be aligned with each other. You can click on each layer's visibility icon in the Layers panel to toggle it on and off and see what changes Photoshop has made to get them aligned. I'll click on my bottom layer's visibility icon to turn that layer off temporarily:

Clicking the visibility icon for the bottom layer in the Layers panel.
Hiding the bottom layer.

This lets me view just the top image, and here we can see that to get both photos aligned, Photoshop resized and rotated the top image. The checkerboard pattern around the image is Photoshop's way of representing transparency:

Clicking the visibility icon for the bottom layer in the Layers panel.
The top image was resized and rotated to align it with the bottom image.

I'll click the same visibility icon once again to turn the bottom layer back on:

Clicking the empty square to toggle the layer visibility back on.
Clicking the empty square to toggle the visibility back on.

And now, we see just how great of a job Photoshop has done. There is a noticeable horizontal line cutting across the image near the top where the shade of blue in the sky doesn't match between photos, but I'll fix that in a moment. Overall, Photoshop did an amazing job:

The images after running the Auto-Align Layers command.
The images after running the Auto-Align Layers command.

Step 4: Select The Top Layer

Now that our images are aligned, we can use a layer mask to hide the unwanted areas in the top image and reveal the better versions from the image underneath. Click on the top layer in the Layers panel to select it, which deselects the bottom layer at the same time:

Selecting the top layer in the Layers panel.
Selecting just the top layer.

Step 5: Add A Layer Mask

Click on the Add Layer Mask icon at the bottom of the Layers panel:

Clicking the Add Layer Mask icon.
Clicking the Add Layer Mask icon.

Nothing will happen to the image in the main document area, but a white-filled layer mask thumbnail appears on the top layer in the Layers panel. If you want to learn more about how layer masks work, be sure to check out our full Understanding Layer Masks in Photoshop tutorial:

The Layers panel showing the new layer mask thumbnail.
The Layers panel showing the new layer mask thumbnail.

Step 6: Select The Brush Tool

To hide the unwanted areas, we'll need to paint on the layer mask with a brush. For that, we'll need Photoshop's Brush Tool. Select the Brush Tool from the Tools panel along the left of the screen:

Selecting the Brush Tool in Photoshop.
Grabbing the Brush Tool.

Step 7: Choose A Soft Round Brush

With the Brush Tool selected, click on the Brush Presets icon in the Options Bar along the top of the screen:

Clicking the Brush Preset icon in the Options Bar.
Clicking the Brush Preset icon.

This opens Photoshop's Brush Preset Picker. Double-click on the first thumbnail (the one in the top left) to select the soft round brush. Double-clicking both selects the brush and then closes out of the Brush Preset Picker:

Double-clicking the soft round brush thumbnail.
Double-clicking the soft round brush thumbnail.

Step 8: Set Your Foreground Color To Black

In order to hide areas on the top layer, with need to paint on the layer mask with black. Photoshop uses the Foreground color as the color of the brush, so to quickly set your Foreground color to black, first press the letter D on your keyboard to make sure your Foreground and Background colors are set to their defaults for working with layer masks. This sets your Foreground color to white and your Background color to black. Then, to swap them so your Foreground color is black, press the letter X on your keyboard.

You can see your current Foreground and Background colors in the color swatches near the bottom of the Tools panel. Your Foreground color swatch is the one in the upper left. It should now be filled with black:

The Foreground color swatch filled with black.
The Foreground color should be black.

Step 9: Paint Over Areas To Hide Them And Reveal The Image Underneath

With a soft round brush in hand and black as the Foreground color, simply paint over any areas in the top image that you want to hide and replace with the same area from the image below it. In my case, I want to replace the horse on the right with the better version of the horse from the other image, so I'll begin painting over the horse. Since I'm painting on the layer mask, not on the image itself, we won't see the black color of my brush strokes. Instead, the top horse begins to disappear in the areas I'm painting over, replaced by the better version of the horse below it. It looks a bit like a science experiment gone wrong at the moment, but it will look better when I'm done:

Painting with black on the layer mask to reveal the horse on the bottom layer.
Painting with black on the mask to swap the horses.

Helpful Tips

Here's a few handy tips to help you out as you're painting on the mask. To change the size of your brush from the keyboard, press the left bracket key ( [ ) repeatedly to make it smaller or the right bracket key ( ] ) to make it larger. To change the hardness of the brush, press and hold the Shift key while pressing the left bracket key to make the edges softer or the right bracket key to make them harder.

If you make a mistake and paint over an area you didn't mean to, press the letter X on your keyboard to swap your Foreground and Background colors, making your Foreground color white. Paint with white over the mistake to bring back the image on the top layer. Then, press X again to switch your Foreground color back to black and continue painting away other areas.

I'll continue painting over the area until I've completely replaced the horse in the top image with the same horse from the bottom image:

Most of the original horse has been replaced with the better version below it.
The original horse has now been replaced with the better version below it.

I also want to make sure I swap out the shadow being cast by the horse, so I'll paint over that area as well:

Painting over the shadow on the ground.
Painting over the shadow on the ground.

Comparing The Original And Composite Versions

If you want to compare the original and composite versions, you can temporarily turn off the layer mask by pressing and holding your Shift key and clicking on the layer mask thumbnail in the Layers panel. A red "X" will appear letting you know the mask has been disabled:

Shift-clicking on the mask thumbnail to temporarily disable it.
Shift-clicking on the mask thumbnail to temporarily disable it.

With the mask disabled, we see the original, unedited version:

The original version of the photo.
The original version of the photo.

Press and hold Shift and click again on the layer mask thumbnail to turn the mask back on and view the composite version:

The composite work-in-progress.
The composite work-in-progress.

To fix that harsh, horizontal line near the top of the image where the shade of blue doesn't match between images, I'll press the right bracket key ( ] ) on my keyboard a few times to make my brush size larger, and with my brush edge still nice and soft, I'll simply paint across that line to create a smooth transition between the photos:

Painting with a large, soft brush across the sky.
Painting with a large, soft brush across the sky.

Viewing The Layer Mask In The Document

If you want to view the actual layer mask itself in the document so you can see exactly where you've painted, press and hold the Alt (Win) / Option (Mac) key on your keyboard and click on the layer mask thumbnail in the Layers panel:

Alt-clicking (Win) / Option-clicking (Mac) on the mask thumbnail.
Alt-clicking (Win) / Option-clicking (Mac) on the mask thumbnail.

This temporarily replaces your image in the document with the layer mask. White represents the areas where the top image remains visible. Areas you've painted over to reveal the image on the bottom layer appear in black. Here, we can see where I've painted over the horse and the sky, and I've also painted along the right edge to smooth out a few more harsh transition edges:

Viewing the layer mask itself in the document.
Viewing the layer mask itself in the document.

To hide the layer mask and switch back to your image, once again press and hold your Alt (Win) / Option (Mac) key and click on the layer mask thumbnail. And with that, we're done! Here is my final composite of the two original photos:

A composite of two images auto-aligned in Photoshop.
The final result.

And there we have it! That's how to easily open, align and merge two images together using the little-known Load Files as Stack command, the powerful Auto-Align Layers command and a simple layer mask in Photoshop! Check out our Photo Retouching section for more Photoshop image editing tutorials!