Page 1 of 1

Merge two PNG images overlapping

Posted: 2017-04-19T01:28:50-07:00
by DieterK
Hello,

i'm searching for an easy way to merge two PNG images with transparency overlapping.

The end result should look like this:
Image

For the output image i need the size 500x750 as a png with transparency.

a.png should be resized to 60% of the output image (or a fixed size) and placed in the bottom left corner.
b.png should be resized to 60% of the output image (or a fixed size) and placed in the top right order (behind a.png)
Both images also have transparency.

Thanks

Dieter

Re: Merge two PNG images overlapping

Posted: 2017-04-19T01:48:01-07:00
by snibgo
What version of IM? I'll assume v6.

What interface? I'll assume the command line.

What platform? I'll assume Windows.

You want to composite a.png over b.png, with both images offset. There are many ways to do this. Here, I create a 500x750 transparent image, composite b.png over it in the NorthEast corner, then a.png at the SouthWest corner.

Code: Select all

convert ^
  -size 500x750 xc:None ^
  -background None ^
  ( b.png -resize 300x450 ) -gravity NorthEast -composite ^
  ( a.png -resize 300x450 ) -gravity SouthWest -composite ^
  out.png

Re: Merge two PNG images overlapping

Posted: 2017-04-19T08:09:56-07:00
by DieterK
Exactly what I was looking for!

Thank you, works perfectly.