Modified script for Raspberry Pi

From MyWiki
Jump to: navigation, search
#!/bin/bash
DEBUG=0
WIDTH=6
COUNTER=1
 
 
 
echo "<HTML>" > index.html
echo "<HEAD>" >> index.html
echo "</HEAD>" >> index.html
echo "<BODY>" >> index.html
echo "<TABLE>" >> index.html
 
 
 
 
rm -f *jpg
#mogrify -resize 200x200 -background white -gravity center -extent 200x200 -format jpg -quality 75 -path . full/*.jpg
mogrify -resize 200x200 -background white -gravity center -format jpg -quality 75 -path . full/*.jpg
 
 
 
 
 
for FILENAME in `ls *.jpg`
 
 
do
echo $FILENAME
YEAR=`echo $FILENAME | cut -c 5-8`
if [ $DEBUG -eq 1 ]
then
echo "The year is $YEAR"
fi
MONTH=`echo $FILENAME | cut -c 9-10`
if [ $DEBUG -eq 1 ]
then
echo "The month is $MONTH"
fi
DAY=`echo $FILENAME | cut -c 11-12`
if [ $DEBUG -eq 1 ]
then
echo "The day is $DAY"
fi
HOUR=`echo $FILENAME | cut -c 13-14`
if [ $DEBUG -eq 1 ]
then
echo "The hour is $HOUR"
fi
MINUTE=`echo $FILENAME | cut -c 15-16`
if [ $DEBUG -eq 1 ]
then
echo "The minute is $MINUTE"
fi
SECOND=`echo $FILENAME | cut -c 17-18`
if [ $DEBUG -eq 1 ]
then
echo "The second is $SECOND"
fi
 
convert $FILENAME -background Khaki label:"${YEAR}/${MONTH}/${DAY} ${HOUR}:${MINUTE}:${SECOND}" -gravity Center -append label.jpg
mv label.jpg $FILENAME 
#
# That ends the creation of thumbnails.
# Not to populate the tuumbnail page
if [ $COUNTER -eq 1 ]
then
echo "<TR>" >> index.html
fi
 
 
echo "<TD> <a href="full/${FILENAME}"><img src="$FILENAME"></a>      </TD>" >> index.html
 
 
if [ $COUNTER -eq $WIDTH ]
then COUNTER=0
echo "</TR>" >> index.html
fi
 
COUNTER=`expr $COUNTER + 1`
 
done