#!/bin/sh

if [ "$1" = "" ]; then
  FILES=*.pnm
else
  FILES=$*
fi

mkdir ../jpg/

for FILE in $FILES ; do
  echo $FILE
  NAME=`echo $FILE | awk 'BEGIN{FS=".";}{s=$1; for(i=2;i<=NF-1;i++){s=s "." $i;} print s;}'`

  convert $FILE -level 12750,51000 -geometry '25%' -sharpen 1,20 -quality 75 ../jpg/$NAME.jpg
done

exit

