Merge two PNG images overlapping

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
DieterK
Posts: 2
Joined: 2017-04-19T01:07:55-07:00
Authentication code: 1151

Merge two PNG images overlapping

Post 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
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Merge two PNG images overlapping

Post 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
snibgo's IM pages: im.snibgo.com
DieterK
Posts: 2
Joined: 2017-04-19T01:07:55-07:00
Authentication code: 1151

Re: Merge two PNG images overlapping

Post by DieterK »

Exactly what I was looking for!

Thank you, works perfectly.
Post Reply