Composite of two images - but top image can be any size

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

Composite of two images - but top image can be any size

Post by oceanthrsty »

So I have a background jpg that is 1500w x 2100h. But this can be adjusted to whatever I need. I've thought just maybe making it 2100x2100.

I want to be able to take a horizontal or vertical main image and place it on top but no matter the size (could be coming in as 3:2 or maybe a pano) be able to make it fit with a border of at least 200px.

Examples of what the output should be:
Vertical Image coming in:
Image

I've started with code that looks like this:

Code: Select all

convert bg.jpg puppy.jpg  -geometry '1900x1900<' -gravity center -composite output.jpg
But I don't know how to account of veri & horizontal. The goal is then to output the image and then print it as a 5x7 print.

Sorry if I'm being vague. just began learning all of the ins an out of IM.
Last edited by oceanthrsty on 2015-03-06T13:42:00-07:00, edited 1 time in total.

User avatar
fmw42
Posts: 26383
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Composite of two images - but top image can be any size

Post by fmw42 »

It is not clear to me what you are trying to do. Can you explain a bit further?

Also you should not use -geometry to resize an image. Use -resize and put it with the image to be resized in parentheses. geometry is primarily for offsetting the pixture relative to your gravity setting. Something like

unix syntax

Code: Select all

convert bg.jpg \( puppy.jpg  -resize '1900x1900<' \) -gravity center -composite output.jpg
window syntax

Code: Select all

convert bg.jpg ( puppy.jpg  -resize '1900x1900<' ) -gravity center -composite output.jpg
You should always provide your version of IM and platform when asking questions.

A good place to start with IM is:
http://www.imagemagick.org/Usage/
http://www.imagemagick.org/Usage/reference.html

oceanthrsty
Posts: 9
Joined: 2014-12-17T15:00:32-07:00
Authentication code: 6789

Re: Composite of two images - but top image can be any size

Post by oceanthrsty »

Basically I need to take a JPG image of unknown size or aspect ratio. Shrink it so the long edge is no bigger then 1680px. Then drop it, centered, onto a background of known size (2100H x 1500W).

I hope that is more clear. And thank you for your mention about not using geometry.

Using IM 6.9.0.9.

Locked