Use ImageMagick to place an image inside a larger canvas

Mike picture Mike · Nov 24, 2009 · Viewed 37.2k times · Source

Getting started with ImageMagic and trying to find a way to do this... If an image is less than 50 pixels tall or 50 pixels wide, I'd like to place it (un-scaled) in the horizontal/vertical center of a new 50x50 pixel canvas on top of a white background - and save that as the new image. Anyone know if this is possible with ImageMagick? Thanks!

Answer

Jared picture Jared · Sep 23, 2010

I used -extent to do this:

convert input.jpg -gravity center -background white -extent 50x50  output.jpg