Can IM resize and pad the image?

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
pchung99

Can IM resize and pad the image?

Post by pchung99 »

Hi,
I have an 400x200 jpg. I want a 800x800 jpg. -resize "800x800!" stretches the image. Is there a way to resize and pad the excess space with white or black so I have an image 800x800 without stretching it?
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Can IM resize and pad the image?

Post by magick »

Try the -extent option.
pchung99

Re: Can IM resize and pad the image?

Post by pchung99 »

That was part I was missing. This is the final code that worked for me.
rs = img.Convert("-resize","800x800","-gravity","center","-extent","800x800","input.jpg","output.jpg")
Thanks for all the help
Great software
Post Reply