Equally sized pictures with border

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
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Equally sized pictures with border

Post by fmw42 »

taghawi wrote:Hello,

I have a batch of different sized pictures. I would like to borders to all of them so that the images are the same size at the end.

Thanks

Davoud

If you want to add borders to them all, so that they are all bigger, but the same size, then figure out the largest size that you want them to be and use -extent. Here is an example that will make all the image 500x500 with a white border

convert inputimage -background white -gravity center -extent 500x500 outputimage

see

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

If you have images that are bigger than your final size, then you can shrink only those to that size or smaller and then add your border using -resize WIDTHxHEIGHT>

see

http://www.imagemagick.org/script/comma ... php#resize
http://www.imagemagick.org/script/comma ... p#geometry

So if you wanted it to have a minimum border of 10, then

convert inputimage -resize 490x490> -background white -gravity center -extent 500x500 outputimage
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Equally sized pictures with border

Post by anthony »

For a general set of examples on this look at IM Examples, Thumbnails. Remember thumbnails are just small images, so what you do for them you can do for larger images too.

http://www.imagemagick.org/Usage/thumbnails/#pad
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply