IM Scripts

From Mmassico

Jump to: navigation, search
#!/bin/bash
rm -R ./album
mkdir ./album
filecount=$(ls -1 *.JPG | wc -l)
echo "$filecount file(s) to process..."
fileindex=0;
for i in *.JPG
do 
   fileindex=$(($fileindex+1))
   percent=$((100*$fileindex/$filecount))
   orientation=$(identify -format %[EXIF:Orientation] $i)
   resize_cmd=""

   if [ "$orientation" = "8" ]
   then
      resize_cmd="-resize 170"
      rotate="clockwise"
   fi

   if [ "$orientation" = "1" ]
   then
      resize_cmd="-resize x170"
      rotate="normal"
   fi

   if [ "$orientation" = "6" ]
   then
      resize_cmd="-resize 170"
      rotate="counterclockwise"
   fi

   echo -n "$fileindex/$filecount (${percent}%) : $i - $rotate ."
   convert -auto-orient ${resize_cmd} "$i" "./album/_thb_$i"
   echo -n "."
   convert -auto-orient -resize 40% "$i" "./album/$i"
   echo "."
done
Personal tools
Navigation