Enlarge image canvas using ImageMagic

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
Sergio
Posts: 3
Joined: 2010-12-27T23:24:13-07:00
Authentication code: 8675308

Enlarge image canvas using ImageMagic

Post by Sergio »

I've been learning about ImageMagick & it's great! For the most part, I can learn on my own, though the one thing that I can't learn to do is to expand the canvas size. So if the ratio is 3x2, I want to add extra white space to make it 3x3. If I use the -geometry function, it enlarges the image to the proportions I want, but it loses the aspect ratio.

If you turn to page 377 (or 388 in PDF) of the User Manual, under "Montage", you'll see that ImageMagic can do what I want. The thumbnails in the example image are all of different proportions but the alloted space is 1x1 for all. However the documentation on this function is pretty bad! Does anyone know how to do this?

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

Re: Enlarge image canvas using ImageMagic

Post by fmw42 »

see -extent, but you need to compute the aspect ratio you want into pixels (and you can use -geometry to position it for center or the sides or corner)

http://www.imagemagick.org/Usage/crop/#extent

You can also use -border http://www.imagemagick.org/Usage/crop/#border

Or try my shell script, aspectpad, at the link below (for linux,mac or windows cygwin)
Sergio
Posts: 3
Joined: 2010-12-27T23:24:13-07:00
Authentication code: 8675308

Re: Enlarge image canvas using ImageMagic

Post by Sergio »

YES! That's exactly what I was looking for. It's going to take a little more doing because I have to calculate height vs width, but it's all in good fun anyway. By the way, your page is AMAZING! It's chock full of scripts, but the impressive part is the documentation and matching pictures! I will make very good use of this page. Thanks!
Post Reply