Dave,
Here is a simpler version that keeps all the calculations within IM
#!/bin/bash
infile="your_infile"
outfile="your_outfile"
dwidth=180 # desired thumbnail width
dheight=130 #desired thumbnail height
test1=`convert $infile -format
"%[fx:((w/h)>(${dwidth}/${dheight})?1:0)]" info:`
test2=`convert $infile -format "%[fx:((w/h)>=1?1:0)]" info:`
if [ $test1 -eq 1 ]
then
echo "aspect larger than desired aspect (wider than tall)"
resize="${dheight}x${dheight}^"
elif [ $test2 -eq 1 ]
then
echo "aspect less than desired aspect (wider than tall) but
greater than or equal to 1"
resize="${dwidth}x${dwidth}"
else
echo "aspect less than 1 (taller than wide)"
resize="${dwidth}x${dwidth}^"
fi
convert $infile +repage -resize $resize \
-gravity Center -crop ${dwidth}x${dheight}+0+0 +repage $outfile
identify -format "%w x %h" $outfile
Fred
_______________________________________________
Magick-users mailing list
[email protected]
http://studio.imagemagick.org/mailman/listinfo/magick-users