Hi, I'm badly need help. Here's is the problem at hand.
#1 I've some 2600 pics to upload in the product catalog of a website
#2 The pics are of very high resolutions (> 4000px in height), but their aspect ratio is not same
#3 I want their aspect ratio to be 1:1.5, i.e., 1000x1500 px. I don't want to crop any, but put padding whenever necessary to maintain the said aspect ratio.
#4 If possible also suggest me how recursively resize all the images.
Suggest me through a simple example.
Thanks in advance.
Resizing and Padding to keep a constant aspect ratio
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Resizing and Padding to keep a constant aspect ratio
Code: Select all
convert image -resize 1000x1500 -background somecolor -gravity center -extent 1000x1500 resultimage
cd to directory containing images
Code: Select all
mogrify -resize 1000x1500 -background somecolor -gravity center -extent 1000x1500 *
See
http://www.imagemagick.org/Usage/basics/#mogrify
If you have multiple directories, you will need to write a script to loop over each directory and use convert on a list of files in each directory or use mogrify.
Re: Resizing and Padding to keep a constant aspect ratio
Thanks. That worked like a charm. Just one issue is unresolved - how to process images recursively, i.e., the images in the subdirectories.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Resizing and Padding to keep a constant aspect ratio
You have to write a script (that depends upon your OS) to loop over each subdirectory that you want to process and do mogrify on each.manmath wrote:Thanks. That worked like a charm. Just one issue is unresolved - how to process images recursively, i.e., the images in the subdirectories.
You have not provided what version of IM you are using nor what OS.
Re: Resizing and Padding to keep a constant aspect ratio
I'm working on ImageMagick-6.7.8.9-10.el7.x86_64 on CEntOS 7.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Resizing and Padding to keep a constant aspect ratio
What was your exact command line?manmath wrote:Thanks. That worked like a charm. Just one issue is unresolved - how to process images recursively, i.e., the images in the subdirectories.
Re: Resizing and Padding to keep a constant aspect ratio
mogrify -resize 1000x1500 -background white -gravity center -extent 1000x1500 *