#!/bin/sh
#set -x
albumname='none'
albumdesc='none'

if [ $# -eq 1 ] ; then
photodir=$1
outdir=$1_web
else
photodir='/d6/edl/MANU/Photo/SummerSchool'
outdir='/d6/edl/MANU/Photo/SummerSchool_web'
fi


currdir=`pwd`
mkdir $outdir

ext='*.JPG *.jpg *.gif *.GIF'
#
P_BIG=35	# reducement factors in % for big and thumbnails
P_THUMB=8
#list files in albumlist
cd ${photodir}
rm $outdir/albumlist.txt
for  filein in `ls -1 ${ext}`  ; do
################################################

fileout=`echo ${filein} | cut -f1 -d"."`


echo $fileout

   echo "$fileout|" >> $outdir/albumlist.txt


done
cd $outdir


cd ${photodir}
for  filein in `ls -1 ${ext}`  ; do
################################################

fileout=`echo ${filein} | cut -f1 -d"."`


echo $fileout

SIZE=`convert -verbose $filein $outdir/dummy | cut -d ' ' -f 2,2`
XS=`echo $SIZE | cut -d x -f 1,1`
YS=`echo $SIZE | cut -d x -f 2,2`


if [ $XS -gt $YS ] ; then 
FACTOR=$XS ; 
else
FACTOR=$YS
fi

FAC=`expr 1600 \* $P_THUMB \/ $FACTOR`
convert -geometry ${FAC}% -quality 85 $filein $outdir/${fileout}_th.jpg

FAC=`expr 1600 \* $P_BIG \/ $FACTOR`
convert -geometry ${FAC}% -quality 85 $filein $outdir/${fileout}_big.jpg


done

# should not be necessary
# mv *_th.jpg *_big.jpg $outdir

cd $currdir
cp create_album.cgi  disp.cgi rotate.sh rotatelist  $outdir

#make the album
cd $outdir
./create_album.cgi
cd $currdir


exit

for  file in `ls -1 *.MOV | cut -f1 -d"."`  ; do
################################################

echo $file
echo ${file}.MOV'|Movie '${file} >> ../album.txt

done
####
create_album.cgi*
 cp disp.cgi taowed/disp.cgi 


dummy
index.cgi*
setup.sh*
taowed/

