--- scripts/pgallery/src/pgallery.sh 2012/08/28 12:30:30 1.6 +++ scripts/pgallery/src/pgallery.sh 2012/08/28 17:37:11 1.9 @@ -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.5 2012/08/28 10:44:41 as Exp $ +# $Paefchen: scripts/pgallery/src/pgallery.sh,v 1.8 2012/08/28 17:29:32 as Exp $ # ARG_TITLE="PGallery" @@ -23,14 +23,17 @@ ARG_INFOFILE="" ARG_MAILTO="" ARG_MAILFROM="PGallery <${USER}@${HOST}>" ARG_URL= +ARG_EXIF="0x920a 0x829d 0x829a ISO 0x8827 / 0x010f - 0x0110" BIN_CONVERT="/usr/local/bin/convert" BIN_EXIFAUTOTRAN="/usr/local/bin/exifautotran" BIN_IMGINFO="/usr/local/bin/imginfo" BIN_SENDMAIL="/usr/sbin/sendmail" +BIN_EXIFTRAN="/usr/local/bin/exiftran" +BIN_EXIF="/usr/local/bin/exif" MKAKEFILE=".htmakefile" -VERSION="pgallery-1.1" +VERSION="pgallery-1.2" # # usage() @@ -40,13 +43,15 @@ usage() cat <] | [-s ] ) [-d ] [-n ] [-t ] [-u ] - [-b ] [-c ] [-l link] + [-b ] [-c ] [-l link] [-e ] [-i ] [-C ] [-F ] [-T ] [-U] | -h | -v Options: -b size size from big images in pixel (default: $ARG_BIGSIZE) -c quality quality from big images 0-100% (default: $ARG_BIGQALITY) -d dir gallery dir (default: $ARG_DIR) + -e exif list of tags in hex. (default: $ARG_EXIF) + see: http://www.exiv2.org/tags.html -f files gallery images -h this page -i name index file name (default: $ARG_INDEX) @@ -64,6 +69,7 @@ Options: the syntax of the file is MAKE(1) supported variable: TITLE COPYRIGHT INDEX FILETYPES TNSIZE URL TNQALITY BIGSIZE BIGQALITY MAILTO MAILFROM + EXIF -T mailto send update infos to this address. if not set, no mail delivery -U no update, new calculation of all images. normally only new and modified images will calculated @@ -154,6 +160,7 @@ HLaErzv/wD99ABmjNZk0AAAAABJRU5ErkJggg=="); font-family: Geneva,Arial,sans-serif; font-size: 12px; text-shadow: 1px 1px 1px #000; + color: #808080; } div.tn { float: left; @@ -238,11 +245,14 @@ div.box { width: ${ARG_BIGSIZE}px; margin: auto; } -div.box div.c { +div.box div.d { width: ${ARG_BIGSIZE}px; - text-align: right; + padding: 5px; + text-align: center; +} +div.box div.i { + width: ${ARG_BIGSIZE}px; font-size: 90%; - color: #808080; height: 25px; line-height: 25px; position: relative; @@ -251,7 +261,6 @@ div.box div.c { body > div.c { text-align: center; font-size: 90%; - color: #808080; height: 25px; line-height: 25px; position: relative; @@ -332,15 +341,22 @@ HTML # html_img() { - img=$1 - link=$2 - linkb=$3 - linkn=$4 + orig=$1 + img=$2 + link=$3 + linkb=$4 + linkn=$5 info=$($BIN_IMGINFO -f $img) width=$(echo $info | awk '{print $3}') height=$(echo $info | awk '{print $4}') + desc=$(get_exif_desc $orig) + if [ "$desc" != "" ] + then + desc="
$desc
" + fi + if [ "$linkb" != "" ] then hlinkb="zurück" @@ -363,8 +379,10 @@ html_img()
$img
-
- $ARG_TITLE $ARG_COPYRIGHT + $desc +
+
$(get_exif_info $orig)
+
$ARG_TITLE $ARG_COPYRIGHT
$olinkb @@ -402,6 +420,47 @@ MAIL ) | $BIN_SENDMAIL -t } +# +# get_exif_desc() +# +get_exif_desc() +{ + img=$1 + $BIN_EXIF --ifd=0 --tag=0x010e -m $img 2> /dev/null | iconv -t ISO-8859-1 -f UTF-8 | while read line + do + echo "$line
" + done +} + +# +# get_exif_value() +# +get_exif_value() +{ + img=$1 + hex=$2 + $BIN_EXIFTRAN -d $img | grep $hex | sed -E 's/^.{45}//' +} + +# +# get_exif_info() +# +get_exif_info() +{ + img=$1 + exifinfo= + for exif in $ARG_EXIF + do + if echo $exif | grep -q -E '0x[[:alnum:]]{4}' + then + exifinfo="$exifinfo$(get_exif_value $img $exif) " + else + exifinfo="$exifinfo$exif " + fi + done + echo $exifinfo | sed -e 's/ mm /mm /' -e 's/ sec./s/' -e 's/ ISO / ISO/' +} + # parse args while [ "$1" != "" ] do @@ -437,6 +496,9 @@ do -d) ARG_DIR=$1 shift;; + -e) + ARG_EXIF=$1 + shift;; -C) ARG_COPYRIGHT=$1 shift;; @@ -465,7 +527,7 @@ if [ "$ARG_INFOFILE" != "" ] then test -f $ARG_INFOFILE || err "info file not found \`\`$ARG_INFOFILE''" for n in TITLE COPYRIGHT INDEX FILETYPES TNSIZE TNQALITY BIGSIZE \ - BIGQALITY MAILTO MAILFROM URL + BIGQALITY MAILTO MAILFROM URL EXIF do v=$(make -f $ARG_INFOFILE -V$n) test "$v" = "" && continue @@ -604,7 +666,7 @@ do index="$index $(html_tn $tn $imglink)" ( html_header - html_img $big $ARG_INDEX "$linkb" "$linkn" + html_img $file $big $ARG_INDEX "$linkb" "$linkn" html_footer ) > $imglink done