Is there a way to batch remove the same background from multiple images?


Someone asked me a Photoshop question the other day, and after some time thinking on it I couldn't come up with an answer - hoping someone here can shed some light!

Let's say I've got a batch of photos of people all standing in front of the same textured background - for example, headshots against a studio background. If I wanted to remove the background from all these photos, there are a few ways to go about it; the problem is all methods I know are manual, and large batches become pretty tedious.

Now, let's say the background in each photo was stationary (maybe a few px of wobble), and I had a photo of the complete background without any figure blocking it. Would there be a way to use the complete background as some sort of inverse/subtractive mask, so all you're left with is the person? At the heart of it, this is about automating the process of removing the same background from every image - so any alternate methods are welcome too. Thanks in advance!

1/29/2015 3:34:00 AM

Accepted Answer

What you are looking for is known as a difference mask, difference key, or difference matte. To get clean results, you'll need a very stationary background.

I'm not the best at creating actions, but here is the sequence I was able to come up with. This assumes you start out with the foreground layer as "Layer 2" and the background layer as "Layer 1".

Difference mask action Layer panel screenshot

Here's the action in ... action:

Difference mask script

And here's a link to download it (test images 1, 2). Anyone more proficient than I with actions can feel free to suggest ways to improve that

Laptop and garden photos courtesy of

6/6/2018 2:05:00 PM