I have some photos of different sizes which I need to resize to fit within a rectangle of 576px X 432px while preserving their aspect ratios. I then need to center each photo on a blue background of exactly 720px X 540px. Most original photos are larger than 720x540, a few are smaller. I've used mogrify to resize the original photos into another folder:
mogrify -format bmp -path ..\name-of-target-folder -resize 576x432 *.*
How do I then center each of these resized images on a new image of 720x540, surrounding the photos with a blue background (#2f3699)?
Can this be done with a single IM command? (If so, how?) If not, what command(s) should I perform after this mogrify?
Thanks,
FastBill
How to center pictures on colored background?
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: How to center pictures on colored background?
Sorry, I don't know mogrify. With convert, you could "-background #2f3699 -gravity center -entent 720x540". This might also work in mogrify.
See http://www.imagemagick.org/script/comma ... php#extent
See http://www.imagemagick.org/script/comma ... php#extent
snibgo's IM pages: im.snibgo.com
Re: How to center pictures on colored background?
Thanks...For testing, I have 4 JPG photos. Each photo is larger than 576 x 432. I tried this command:
The result was that each photo was resized to 720 x 540, completely filling that space with no blue background. Not what I was hoping for.
Next, I tried this sequence of commands:
The mogrify command converted each of the photos to a BMP, resizing each one to fit within a 576x432 rectangle. It maintained the aspect ratio of each photo. Then, applying the convert command to these resized images centered each of them in a 720x540 blue rectangle.
Success! Thanks for your help.
Code: Select all
convert 0*.jpg -background #2f3699 -gravity center -extent 720x540 Slide%d.png
Next, I tried this sequence of commands:
Code: Select all
mogrify -format bmp -path ..\TEST_OUT -resize 576x432 *.*
convert 0*.bmp -background #2f3699 -gravity center -extent 720x540 Slide%d.png
Success! Thanks for your help.
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: How to center pictures on colored background?
Yes, each image needs to be resized before the extent. You might find you can do resize and extent in a single mogrify. I don't know.
snibgo's IM pages: im.snibgo.com