I have hundreds of images which width and height may vary. I want to resize all of them with this requirements:
Make them smaller so the largest side should get 2560px or the shortest size should be 1600px. Right now I'm using this code:
for file in
ls
; do convert $file -resize "2560>" new-$file;donefor file in
ls
; do convert $file -resize "1600^>" new-$file;doneNever the largest side should be less than 2560 or the shortest size less than 1600px
It would be awesome to crop extra space so my final images should be 2560x1600 (landscape) or 1600x2560 (portrait).
For instance if my image is 4000x3000, I may get 2560x1920 or 2133x1600. I would like to keep 2560x1920 and crop 160 pixels from both top and bottom of it to get 2560x1600.
Code I use right now is this:
for i in `ls`; do convert $i -resize '2560x1600^' -gravity center -crop '2560x1600+0+0' new-$i; done
But if my image is 3000x4000 (portrait mode), I may get 2560x3413 and then it crops till I get 2560x1600 where I would want 1600x2560.