version 1.6, 2012/08/28 12:30:30
|
version 1.11, 2012/08/29 11:21:41
|
Line 5
|
Line 5
|
# can do whatever you want with this stuff. If we meet some day, and you think |
# 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 |
# 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.10 2012/08/29 10:52:35 as Exp $ |
# |
# |
|
|
ARG_TITLE="PGallery" |
ARG_TITLE="PGallery" |
Line 23 ARG_INFOFILE=""
|
Line 23 ARG_INFOFILE=""
|
ARG_MAILTO="" |
ARG_MAILTO="" |
ARG_MAILFROM="PGallery <${USER}@${HOST}>" |
ARG_MAILFROM="PGallery <${USER}@${HOST}>" |
ARG_URL= |
ARG_URL= |
|
ARG_EXIF="0x920a 0x829d 0x829a ISO 0x8827 / 0x010f - 0x0110" |
|
|
BIN_CONVERT="/usr/local/bin/convert" |
BIN_CONVERT="/usr/local/bin/convert" |
BIN_EXIFAUTOTRAN="/usr/local/bin/exifautotran" |
BIN_EXIFAUTOTRAN="/usr/local/bin/exifautotran" |
BIN_IMGINFO="/usr/local/bin/imginfo" |
BIN_IMGINFO="/usr/local/bin/imginfo" |
BIN_SENDMAIL="/usr/sbin/sendmail" |
BIN_SENDMAIL="/usr/sbin/sendmail" |
|
BIN_EXIFTRAN="/usr/local/bin/exiftran" |
|
BIN_EXIF="/usr/local/bin/exif" |
|
|
MKAKEFILE=".htmakefile" |
MKAKEFILE=".htmakefile" |
VERSION="pgallery-1.1" | VERSION="pgallery-1.2" |
|
|
# |
# |
# usage() |
# usage() |
Line 40 usage()
|
Line 43 usage()
|
cat <<USAGE |
cat <<USAGE |
usage $0: ( [-f <files>] | [-s <suffix>] ) [-d <dir>] [-n <name>] |
usage $0: ( [-f <files>] | [-s <suffix>] ) [-d <dir>] [-n <name>] |
[-t <thumbnail_size>] [-u <thumbnail_quality>] |
[-t <thumbnail_size>] [-u <thumbnail_quality>] |
[-b <big_size>] [-c <big_quality>] [-l link] | [-b <big_size>] [-c <big_quality>] [-l link] [-e <exif>] |
[-i <index>] [-C <copyright>] [-F <mailfrom>] [-T <mailto>] |
[-i <index>] [-C <copyright>] [-F <mailfrom>] [-T <mailto>] |
[-U] | -h | -v |
[-U] | -h | -v |
Options: |
Options: |
-b size size from big images in pixel (default: $ARG_BIGSIZE) |
-b size size from big images in pixel (default: $ARG_BIGSIZE) |
-c quality quality from big images 0-100% (default: $ARG_BIGQALITY) |
-c quality quality from big images 0-100% (default: $ARG_BIGQALITY) |
-d dir gallery dir (default: $ARG_DIR) |
-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 |
-f files gallery images |
-h this page |
-h this page |
-i name index file name (default: $ARG_INDEX) |
-i name index file name (default: $ARG_INDEX) |
Line 64 Options:
|
Line 69 Options:
|
the syntax of the file is MAKE(1) |
the syntax of the file is MAKE(1) |
supported variable: TITLE COPYRIGHT INDEX FILETYPES TNSIZE URL |
supported variable: TITLE COPYRIGHT INDEX FILETYPES TNSIZE URL |
TNQALITY BIGSIZE BIGQALITY MAILTO MAILFROM |
TNQALITY BIGSIZE BIGQALITY MAILTO MAILFROM |
|
EXIF |
-T mailto send update infos to this address. if not set, no mail delivery |
-T mailto send update infos to this address. if not set, no mail delivery |
-U no update, new calculation of all images. |
-U no update, new calculation of all images. |
normally only new and modified images will calculated |
normally only new and modified images will calculated |
Line 154 HLaErzv/wD99ABmjNZk0AAAAABJRU5ErkJggg==");
|
Line 160 HLaErzv/wD99ABmjNZk0AAAAABJRU5ErkJggg==");
|
font-family: Geneva,Arial,sans-serif; |
font-family: Geneva,Arial,sans-serif; |
font-size: 12px; |
font-size: 12px; |
text-shadow: 1px 1px 1px #000; |
text-shadow: 1px 1px 1px #000; |
|
color: #808080; |
} |
} |
div.tn { |
div.tn { |
float: left; |
float: left; |
Line 238 div.box {
|
Line 245 div.box {
|
width: ${ARG_BIGSIZE}px; |
width: ${ARG_BIGSIZE}px; |
margin: auto; |
margin: auto; |
} |
} |
div.box div.c { | div.box div.d { |
width: ${ARG_BIGSIZE}px; |
width: ${ARG_BIGSIZE}px; |
text-align: right; | padding: 5px; |
| text-align: center; |
| } |
| div.box div.i { |
| width: ${ARG_BIGSIZE}px; |
font-size: 90%; |
font-size: 90%; |
color: #808080; |
|
height: 25px; |
height: 25px; |
line-height: 25px; |
line-height: 25px; |
position: relative; |
position: relative; |
Line 251 div.box div.c {
|
Line 261 div.box div.c {
|
body > div.c { |
body > div.c { |
text-align: center; |
text-align: center; |
font-size: 90%; |
font-size: 90%; |
color: #808080; |
|
height: 25px; |
height: 25px; |
line-height: 25px; |
line-height: 25px; |
position: relative; |
position: relative; |
Line 332 HTML
|
Line 341 HTML
|
# |
# |
html_img() |
html_img() |
{ |
{ |
img=$1 | orig=$1 |
link=$2 | img=$2 |
linkb=$3 | link=$3 |
linkn=$4 | linkb=$4 |
| linkn=$5 |
|
|
info=$($BIN_IMGINFO -f $img) |
info=$($BIN_IMGINFO -f $img) |
width=$(echo $info | awk '{print $3}') |
width=$(echo $info | awk '{print $3}') |
height=$(echo $info | awk '{print $4}') |
height=$(echo $info | awk '{print $4}') |
|
|
|
desc=$(get_exif_desc $orig) |
|
if [ "$desc" != "" ] |
|
then |
|
desc="<div class='d'>$desc</div>" |
|
fi |
|
|
if [ "$linkb" != "" ] |
if [ "$linkb" != "" ] |
then |
then |
hlinkb="<a href='$linkb'>zurück</a>" |
hlinkb="<a href='$linkb'>zurück</a>" |
Line 363 html_img()
|
Line 379 html_img()
|
<div class="big"> |
<div class="big"> |
<img alt="$img" width="$width" height="$height" src="$img" /> |
<img alt="$img" width="$width" height="$height" src="$img" /> |
</div> |
</div> |
<div class="c"> | $desc |
$ARG_TITLE $ARG_COPYRIGHT | <div class="i"> |
| <div class="left">$(get_exif_info $orig)</div> |
| <div class="right">$ARG_TITLE $ARG_COPYRIGHT</div> |
</div> |
</div> |
<div class="over" style='height:${height}px'> |
<div class="over" style='height:${height}px'> |
$olinkb |
$olinkb |
Line 402 MAIL
|
Line 420 MAIL
|
) | $BIN_SENDMAIL -t |
) | $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<br />" |
|
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/' |
|
} |
|
|
|
# |
|
# 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 |
# parse args |
while [ "$1" != "" ] |
while [ "$1" != "" ] |
do |
do |
Line 437 do
|
Line 510 do
|
-d) |
-d) |
ARG_DIR=$1 |
ARG_DIR=$1 |
shift;; |
shift;; |
|
-e) |
|
ARG_EXIF=$1 |
|
shift;; |
-C) |
-C) |
ARG_COPYRIGHT=$1 |
ARG_COPYRIGHT=$1 |
shift;; |
shift;; |
Line 465 if [ "$ARG_INFOFILE" != "" ]
|
Line 541 if [ "$ARG_INFOFILE" != "" ]
|
then |
then |
test -f $ARG_INFOFILE || err "info file not found \`\`$ARG_INFOFILE''" |
test -f $ARG_INFOFILE || err "info file not found \`\`$ARG_INFOFILE''" |
for n in TITLE COPYRIGHT INDEX FILETYPES TNSIZE TNQALITY BIGSIZE \ |
for n in TITLE COPYRIGHT INDEX FILETYPES TNSIZE TNQALITY BIGSIZE \ |
BIGQALITY MAILTO MAILFROM URL | BIGQALITY MAILTO MAILFROM URL EXIF |
do |
do |
v=$(make -f $ARG_INFOFILE -V$n) |
v=$(make -f $ARG_INFOFILE -V$n) |
test "$v" = "" && continue |
test "$v" = "" && continue |
Line 579 echo "tns: $targets" >> $MKAKEFILE
|
Line 655 echo "tns: $targets" >> $MKAKEFILE
|
make -f $MKAKEFILE |
make -f $MKAKEFILE |
rm $MKAKEFILE |
rm $MKAKEFILE |
|
|
# create single html files | # create html index |
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 "<div class='clear'></div>" |
|
echo "<div class='c'>$ARG_TITLE $ARG_COPYRIGHT</div>" |
|
html_footer |
|
) > $ARG_INDEX |
|
|
|
# create single html files |
|
#test $ARG_UPDATE -eq 1 && FLIST="$FLIST_NEW $FLIST_UPDATE" |
i=0 |
i=0 |
echo -n "create single html files " |
echo -n "create single html files " |
for file in $FLIST |
for file in $FLIST |
Line 589 do
|
Line 682 do
|
i=$(($i + 1)) |
i=$(($i + 1)) |
j=$(($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" |
big="${file}.big.jpg" |
imglink="${file}.html" |
imglink="${file}.html" |
|
|
Line 601 do
|
Line 699 do
|
test "$linkn" != "" && linkn="$linkn.html" |
test "$linkn" != "" && linkn="$linkn.html" |
|
|
echo -n . |
echo -n . |
index="$index $(html_tn $tn $imglink)" |
|
( |
( |
html_header |
html_header |
html_img $big $ARG_INDEX "$linkb" "$linkn" | html_img $file $big $ARG_INDEX "$linkb" "$linkn" |
html_footer |
html_footer |
) > $imglink |
) > $imglink |
done |
done |
echo |
echo |
|
|
# create html index |
|
echo create html index |
|
( |
|
html_header |
|
echo $index |
|
echo "<div class='clear'></div>" |
|
echo "<div class='c'>$ARG_TITLE $ARG_COPYRIGHT</div>" |
|
html_footer |
|
) > $ARG_INDEX |
|
|
|
|
|
test "$ARG_MAILTO" = "" && exit 0 |
test "$ARG_MAILTO" = "" && exit 0 |
|
|