Composite PNG and Background

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
oceanthrsty
Posts: 9
Joined: 2014-12-17T15:00:32-07:00
Authentication code: 6789

Composite PNG and Background

Post by oceanthrsty »

My background can be any JPG or GIF of pretty much any size. I need to lay a PNG on it, centered and touching the bottom edge.

The PNGs are HUGE. So when I composite them, the PNG is not resized, it's just cut out to match the background size

What I've got now is:

Code: Select all

composite -gravity center person.png background.jpg result.jpg
I know I need a resize in there, but I don't know how to size it to match.

Windows
IM 6.9
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Composite PNG and Background

Post by snibgo »

centered and touching the bottom edge
This is "-gravity south", not "-gravity center".

I would use "convert", not "composite". Eg for Windows BAT:

Code: Select all

convert background.jpg ( person.png -resize X%% ) -gravity South -composite result.jpg
The value of X might be, for example, the height of background.jpg divided by the height of person.png, multiplied by 100 or 90. Do this in a script.
snibgo's IM pages: im.snibgo.com
oceanthrsty
Posts: 9
Joined: 2014-12-17T15:00:32-07:00
Authentication code: 6789

Re: Composite PNG and Background

Post by oceanthrsty »

Awesome... that works great!

Thanks!
Post Reply