Объединить два изображения с прозрачностью в imagemagick

3238
tiimowad

У меня есть два изображения без прозрачности (две фотографии), и я хочу объединить эти изображения в одно изображение, где первое изображение покрывает второе изображение. Как масштабировать эти изображения до одинакового размера и объединить с прозрачностью, как в примере ниже?

пример результата

4
Вы можете прочитать эту страницу: http://www.imagemagick.org/Usage/compose/#compose daniel.neumann 8 лет назад 0

1 ответ на вопрос

5
Hastur

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 -gravity Center \
1.gif 2.gif -alpha Set

Похожие вопросы