resize thumbnails of different proportion to fit output size

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?".
Post Reply
schel4ok
Posts: 18
Joined: 2015-08-31T10:38:58-07:00
Authentication code: 1151

resize thumbnails of different proportion to fit output size

Post 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
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: resize thumbnails of different proportion to fit output size

Post 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.
schel4ok
Posts: 18
Joined: 2015-08-31T10:38:58-07:00
Authentication code: 1151

Re: resize thumbnails of different proportion to fit output size

Post by schel4ok »

thanks. It helped me
Post Reply