Graphic Design Stack Exchange is a question and answer site for Graphic Design professionals, students, and enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have two images A and B which are similar in many regions.

I want to create an image C so that

B = C on top of A

where C should be as transparent as possible. on top of is the normal layer superposition.

So C is some kind of difference between A and B. If A and B are identical, then C is totally transparent. If A and B are very different, then their C would be nearly identical to B.

share|improve this question
There's a great answer to this question on Stack Overflow that uses ImageMagick:… – alberge May 17 at 5:56

You could use the "difference" layer mode to create a layer mask, and apply it to B like this:

  1. Open both images as layers, A on the bottom, B on top
  2. On the layer's dialog, mark B's layer mode as "difference". You now should see the image mostly black is the images are alike, with the colored areas marking the areas that are different. These colors, however, won't match B's colors as you want
  3. Edit->Copy visible, to get a copy of the calculated effect on B
  4. Duplicate Layer B, change it's mode back to "Normal" (let's call this layer C)
  5. On the Layers menu, add a layer mask to C (Layer->Mask->Add Layer Mask).
  6. With the mask selected, paste the contents copied in step 3 (edit->paste).
  7. Anchor the pasted contents on the layer's mask (layer->Anchor layer)

There you are - make Layers A and B invisible, and you should be very close to what you want. Further operations on the layer mask (I recommend using Colors->curve) can adjust the opacity/transparency of the areas on layer C.

update I recently answered a similar question to this on Stackoverflow, where the OP wanted to perform the task programatically (Using Python + Python-imaging-library) - I've posted the full program on that question and it might be of help for anyone interested in this answer:

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.