How to enlarge canvas of various images to one 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?".
Post Reply
coldkingnowhere
Posts: 7
Joined: 2011-11-01T13:36:39-07:00
Authentication code: 8675308

How to enlarge canvas of various images to one size

Post by coldkingnowhere »

Part of what I'm currently trying to do has me resizing a number of images to be within 800x800px (but they all have different aspect ratios) and then center each image on a 1920x1080 canvas.

All of the functions I've looked at (-border, -extent, -frame, -splice) seem to be dependent on adding a constant number of pixels to the canvas but I want the same canvas size (1920x1080) no matter what image is being processed without altering that image in any other way.

Ideas?
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: How to enlarge canvas of various images to one size

Post by Bonzo »

Try:

Code: Select all

convert -size 1920x1080 xc:white image.jpg -gravity center -composite output.jpg
OR

Code: Select all

convert image.jpg -background white -gravity center -extent 1920x1080 output.jpg
coldkingnowhere
Posts: 7
Joined: 2011-11-01T13:36:39-07:00
Authentication code: 8675308

Re: How to enlarge canvas of various images to one size

Post by coldkingnowhere »

That worked great! Thanks.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: How to enlarge canvas of various images to one size

Post by anthony »

Bonzo wrote:

Code: Select all

convert image.jpg -background white -gravity center -extent 1920x1080 output.jpg
to include the resize... to fit in a 800x800 area in the center of the 1920x1080 canvas image...

Code: Select all

convert image.jpg -resize 800x800 -background white -gravity center -extent 1920x1080 output.jpg
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply