Merge two images with transparency in imagemagick

imagemagickimagesmergemontagetransparency

I have two images without transparency (two photos) and I want to combine these images into one image where first image covers second image. How to scale these images to the same size and merge with transparency like in example below?

example result

Best Answer

Imagemagick is a complex tool with a lot of options.
In the example you posted it seems that to the first image is superimposed (overlapped) a copy flipped with some transparency level. All actions that you can do at the price of a complicate commandline.

Let's suppose, for sake of simplicity, that you have just ready the two images. Give it a look to [1],[2] to understand better how it works. In the second reference [2] you can have a guess by examples about the methods available in Imagemagick to add two images.

Probably the -dissolve [3] or the -blend [4] option is what you are searching for:

composite -dissolve 50 -gravity Center a.jpg b.jpg -alpha Set result.jpg

Another way to do it can be [5]

convert FUfstEv.jpg  \
\( ChYNTch.jpg -alpha set -channel a -evaluate set 50% +channel \) \
-gravity center -compose over -composite result1.jpg

Additional operation may have to be added to scale the image if needed... As additional reference you can see [n]. See again this page [5] for some examples.

In general the syntax of the dissolve option can be similar to the following one:

composite -dissolve {argument} -gravity Center \
1.gif 2.gif -alpha Set {result}

Related Question