--- scripts/pgallery/src/pgallery.sh 2012/08/28 17:29:32 1.8 +++ scripts/pgallery/src/pgallery.sh 2012/08/29 12:30:35 1.12 @@ -5,7 +5,7 @@ # can do whatever you want with this stuff. If we meet some day, and you think # this stuff is worth it, you can buy me a beer in return Aron Schlesinger # -# $Paefchen: scripts/pgallery/src/pgallery.sh,v 1.7 2012/08/28 17:08:34 as Exp $ +# $Paefchen: scripts/pgallery/src/pgallery.sh,v 1.11 2012/08/29 11:21:41 as Exp $ # ARG_TITLE="PGallery" @@ -33,7 +33,7 @@ BIN_EXIFTRAN="/usr/local/bin/exiftran" BIN_EXIF="/usr/local/bin/exif" MKAKEFILE=".htmakefile" -VERSION="pgallery-1.1" +VERSION="pgallery-1.2" # # usage() @@ -256,7 +256,6 @@ div.box div.i { height: 25px; line-height: 25px; position: relative; - left: 4px; } body > div.c { text-align: center; @@ -342,10 +341,12 @@ HTML html_img() { orig=$1 - img=$2 - link=$3 - linkb=$4 - linkn=$5 + num=$2 + all=$3 + img=$4 + link=$5 + linkb=$6 + linkn=$7 info=$($BIN_IMGINFO -f $img) width=$(echo $info | awk '{print $3}') @@ -359,20 +360,22 @@ html_img() if [ "$linkb" != "" ] then - hlinkb="zurück" + hlinkb="back" olinkb="" fi if [ "$linkn" != "" ] then - hlinkn="weiter" + hlinkn="forward" olinkn="" fi cat < @@ -433,6 +436,26 @@ get_exif_desc() } # +# get_exif_ts() +# +get_exif_ts() +{ + img=$1 + date=$($BIN_EXIF --ifd=EXIF --tag=0x9003 -m $img 2> /dev/null) + test "$date" = "" && return 1 + date -j -f "%Y:%m:%d %T" "$date" "+%s" +} + +# +# get_exif_date() +# +get_exif_date() +{ + img=$1 + ts=$(get_exif_ts $img) && date -r $ts "+%d.%m.%Y %H:%M" || echo "" +} + +# # get_exif_value() # get_exif_value() @@ -448,7 +471,10 @@ get_exif_value() get_exif_info() { img=$1 + exifinfo= + created=$(get_exif_date $img) && exifinfo="$created / " + for exif in $ARG_EXIF do if echo $exif | grep -q -E '0x[[:alnum:]]{4}' @@ -458,9 +484,23 @@ get_exif_info() exifinfo="$exifinfo$exif " fi done - echo $exifinfo | sed -e 's/ mm /mm /' -e 's/ sec./s/' -e 's/ ISO / ISO/' + echo $exifinfo | sed -E -e 's/ mm /mm /' -e 's/ sec./s/' -e 's/ ISO / ISO/' -e 's/ ISO(\/| )/ \1/' } +# +# is_in_list() +# +is_in_list() +{ + list=$1 + value=$2 + for entry in $list + do + test "$entry" = "$value" && return 0 + done + return 1 +} + # parse args while [ "$1" != "" ] do @@ -638,12 +678,30 @@ MAKE done echo "tns: $targets" >> $MKAKEFILE -make -f $MKAKEFILE +#make -f $MKAKEFILE rm $MKAKEFILE -# create single html files +# create html index index="" +for file in $FLIST +do + tn="${file}.tn.jpg" + imglink="${file}.html" + index="$index $(html_tn $tn $imglink)" +done +echo create html index +( + html_header + echo $index + echo "
" + echo "
$ARG_TITLE $ARG_COPYRIGHT
" + html_footer +) > $ARG_INDEX + +# create single html files +#test $ARG_UPDATE -eq 1 && FLIST="$FLIST_NEW $FLIST_UPDATE" i=0 +all=$(echo $FLIST | wc -w) echo -n "create single html files " for file in $FLIST do @@ -651,7 +709,12 @@ do i=$(($i + 1)) j=$(($i + 1)) - tn="${file}.tn.jpg" + # is update mod and no new images founded + if [ $ARG_UPDATE -eq 1 -a "$FLIST_NEW" = "" ] + then + is_in_list "$FLIST_UPDATE" "$file" || continue + fi + big="${file}.big.jpg" imglink="${file}.html" @@ -663,25 +726,13 @@ do test "$linkn" != "" && linkn="$linkn.html" echo -n . - index="$index $(html_tn $tn $imglink)" ( html_header - html_img $file $big $ARG_INDEX "$linkb" "$linkn" + html_img $file $i $all $big $ARG_INDEX "$linkb" "$linkn" html_footer ) > $imglink done echo - -# create html index -echo create html index -( - html_header - echo $index - echo "
" - echo "
$ARG_TITLE $ARG_COPYRIGHT
" - html_footer -) > $ARG_INDEX - test "$ARG_MAILTO" = "" && exit 0