Page 1 of 1

resize thumbnails of different proportion to fit output size

Posted: 2015-09-11T14:02:17-07:00
by schel4ok
I have folder with photos of different orientation. Portrait and album.
But I need to resize them to fit 234x180 thumbnail without white segments.
Now I use code below to solve this issue. So I have separate folders to store portrait and album pictures.
I'm interested maybe it is possible to do the same easier using imagemagick special options?

Code: Select all

smartresize() {   mogrify  -path $1  -thumbnail $2 $3  }

smartresize    public/img/news/           234      'resources/img/news/portrait/*'
smartresize    public/img/news/          x180     'resources/img/news/album/*'

cd public/img/news
for f in *.*
do convert $f -gravity center -extent 234x180 $f;
done

Re: resize thumbnails of different proportion to fit output size

Posted: 2015-09-11T14:11:17-07:00
by fmw42
Put it all into one convert command and skip the mogrify

Code: Select all

cd public/img/news
for f in *.*; do
convert $f -thumbnail 234x180^ -gravity center -crop 234x180+0+0 +repage $f
done
or

Code: Select all

cd public/img/news
for f in *.*; do
convert $f -thumbnail 234x180^ -gravity center -extent 234x180 $f
done

see http://www.imagemagick.org/script/comma ... p#geometry and http://www.imagemagick.org/Usage/thumbnails/#cut

But I would suggest that you put the output into a new directory rather than write over the old image, just in case of an error.

Re: resize thumbnails of different proportion to fit output size

Posted: 2015-09-12T04:59:59-07:00
by schel4ok
thanks. It helped me