add-word-to-image.sh

#!/bin/bash


mv *.jpeg ../web/yesterday
mv ../web/*.jpeg .




SUFFIX=".jpeg"
PREFIX="./"
DIRS="./*$SUFFIX"




for file in $DIRS;do
NAME=${file%$SUFFIX}
NAME=${NAME#$PREFIX}
LEN=${#NAME}


RIGHT_POS=`expr 930 - $LEN \* 20`


RIGHT_POS_BG=`expr 930 - $LEN \* 20 + 2`
TOP_POS_BG=`expr 490 - 2`


# Print date on the image
MONTHNUM=`date "+%-m"`
case $MONTHNUM in
01)
MONTH="January"
;;
02)
MONTH="February"
;;
03)
MONTH="March"
;;
04)
MONTH="April"
;;
05)
MONTH="May"
;;
06)
MONTH="June"
;;
7)
MONTH="July"
;;
08)
MONTH="August"
;;
09)
MONTH="September "
;;
10)
MONTH="October "
;;
11)
MONTH="November"
;;
12)
MONTH="December"
;;
*)
;;
esac
# DATE=`date "+%Y-%m-%d, "`



WEEKNUM=`date "+%u"`
case $WEEKNUM in
1)
WEEK="Monday"
;;
2)
WEEK="Tuesday"
;;
3)
WEEK="Wednesday"
;;
4)
WEEK="Thursday"
;;
5)
WEEK="Friday"
;;
6)
WEEK="Saturday"
;;
7)
WEEK="Sunday"
;;
*)
;;
esac
DATE=`date "+%-d, %Y"`


# DATE_LONG="$DATE""$WEEK"
DATE_LONG="$WEEK, ""$MONTH ""$DATE"


RED=`expr $RANDOM % 256`
BLUE=`expr $RANDOM % 256`
GREEN=`expr $RANDOM % 256`



echo "Processing ${file#$PREFIX} ..."
# echo "$file,$NAME,$LEN,$RIGHT_POS"
# convert -font wqy-microhei.ttc -fill "rgb($RED,$GREEN,$BLUE)"  -stroke "rgb($BLUE,$GREEN,$RED)"  -pointsize 20 -draw "text 379,50 '$DATE_LONG'"  $file $file
# convert -font wqy-microhei.ttc -fill  "rgb(50,50,50)" -pointsize 20 -draw "text 381,52 '$DATE_LONG'"  $file $file
convert -font comic.ttf -fill  "rgb($RED,$GREEN,$BLUE)" -pointsize 20 -draw "text 379,50 '$DATE_LONG'"  $file $file
# convert -font wqy-microhei.ttc -tile fontbg.jpg -pointsize 20 -draw "text 379,50 '$DATE_LONG'"  $file $file


convert -font wqy-microhei.ttc -fill "rgb(0,0,0)" -pointsize 20 -draw "text ${RIGHT_POS_BG},${TOP_POS_BG} '$NAME'"  $file $file
convert -font wqy-microhei.ttc -fill "rgb(192,192,192)" -pointsize 20 -draw "text ${RIGHT_POS},490 '$NAME'"  $file $file


convert $file bottom.gif -append  $file


done



你可能感兴趣的:(Date,File,Random,processing)