Resize image, keep aspect ratio and add white background

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?".
Locked
sakis_s
Posts: 5
Joined: 2020-02-07T09:40:05-07:00
Authentication code: 1152

Resize image, keep aspect ratio and add white background

Post by sakis_s »

Hi! I've tried so many different things but nothing really works for me. Can someone please help me?

I have many .jpg images inside a folder all 1448x2048 pixels. I'm trying to convert all of them to 1050x1200 pixels and add white background to keep the aspect ratio. I'm using ImageMagick for windows.

Any ideas are much appreciated.

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

Re: Resize image, keep aspect ratio and add white background

Post by fmw42 »

What is your version of Imagemagick?

For IM 6:

Code: Select all

convert image -resize 1050x1200 -gravity center -background white -extent 1050x1200 newimage
For IM 7, replace convert with magick

sakis_s
Posts: 5
Joined: 2020-02-07T09:40:05-07:00
Authentication code: 1152

Re: Resize image, keep aspect ratio and add white background

Post by sakis_s »

fmw42 wrote:
2020-02-21T11:22:24-07:00
What is your version of Imagemagick?

For IM 6:

Code: Select all

convert image -resize 1050x1200 -gravity center -background white -extent 1050x1200 newimage
For IM 7, replace convert with magick
Thank you so much fmw42! Based on your command i was able to change some things for multiple images of a folder and finally i used this:
mogrify -path c:/test -resize 1050x1200 -background white -gravity center -extent 1050x1200 *.jpg
Works perfectly! :D

Locked