version 1.7, 2012/08/28 17:08:34
|
version 1.14, 2012/08/29 13:36:01
|
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.6 2012/08/28 12:30:30 as Exp $ | # $Paefchen: scripts/pgallery/src/pgallery.sh,v 1.13 2012/08/29 12:41:06 as Exp $ |
# |
# |
|
|
ARG_TITLE="PGallery" |
ARG_TITLE="PGallery" |
Line 33 BIN_EXIFTRAN="/usr/local/bin/exiftran"
|
Line 33 BIN_EXIFTRAN="/usr/local/bin/exiftran"
|
BIN_EXIF="/usr/local/bin/exif" |
BIN_EXIF="/usr/local/bin/exif" |
|
|
MKAKEFILE=".htmakefile" |
MKAKEFILE=".htmakefile" |
VERSION="pgallery-1.1" | VERSION="pgallery-1.2" |
|
|
# |
# |
# usage() |
# usage() |
Line 256 div.box div.i {
|
Line 256 div.box div.i {
|
height: 25px; |
height: 25px; |
line-height: 25px; |
line-height: 25px; |
position: relative; |
position: relative; |
left: 4px; |
|
} |
} |
body > div.c { |
body > div.c { |
text-align: center; |
text-align: center; |
Line 342 HTML
|
Line 341 HTML
|
html_img() |
html_img() |
{ |
{ |
orig=$1 |
orig=$1 |
img=$2 | num=$2 |
link=$3 | all=$3 |
linkb=$4 | img=$4 |
linkn=$5 | link=$5 |
| linkb=$6 |
| linkn=$7 |
|
|
info=$($BIN_IMGINFO -f $img) |
info=$($BIN_IMGINFO -f $img) |
width=$(echo $info | awk '{print $3}') |
width=$(echo $info | awk '{print $3}') |
Line 359 html_img()
|
Line 360 html_img()
|
|
|
if [ "$linkb" != "" ] |
if [ "$linkb" != "" ] |
then |
then |
hlinkb="<a href='$linkb'>zurück</a>" | hlinkb="<a href='$linkb'>prev</a>" |
olinkb="<a class='left' style='height:${height}px' href='$linkb'></a>" |
olinkb="<a class='left' style='height:${height}px' href='$linkb'></a>" |
fi |
fi |
|
|
if [ "$linkn" != "" ] |
if [ "$linkn" != "" ] |
then |
then |
hlinkn="<a href="$linkn">weiter</a>" | hlinkn="<a href="$linkn">next</a>" |
olinkn="<a class='right' style='height:${height}px' href='$linkn'></a>" |
olinkn="<a class='right' style='height:${height}px' href='$linkn'></a>" |
fi |
fi |
|
|
cat <<HTML |
cat <<HTML |
<div class="box"> |
<div class="box"> |
<div class="nav"> |
<div class="nav"> |
<div class="top"><a href="$link">Index</a></div> | <div class="top"> |
| <a href="$link">index</a> | <a href="$orig">original</a> | $num/$all |
| </div> |
<div class="left">$hlinkb</div> |
<div class="left">$hlinkb</div> |
<div class="right">$hlinkn</div> |
<div class="right">$hlinkn</div> |
</div> |
</div> |
Line 433 get_exif_desc()
|
Line 436 get_exif_desc()
|
} |
} |
|
|
# |
# |
|
# get_exif_ts() |
|
# |
|
get_exif_ts() |
|
{ |
|
img=$1 |
|
date=$($BIN_EXIF --ifd=EXIF --tag=0x9003 -m $img 2> /dev/null) |
|
if [ "$date" = "" ] |
|
then |
|
echo "-1" |
|
return 1 |
|
fi |
|
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() |
# |
# |
get_exif_value() |
get_exif_value() |
Line 448 get_exif_value()
|
Line 475 get_exif_value()
|
get_exif_info() |
get_exif_info() |
{ |
{ |
img=$1 |
img=$1 |
|
|
exifinfo= |
exifinfo= |
|
created=$(get_exif_date $img) && exifinfo="$created / " |
|
|
for exif in $ARG_EXIF |
for exif in $ARG_EXIF |
do |
do |
if echo $exif | grep -q -E '0x[[:alnum:]]{4}' |
if echo $exif | grep -q -E '0x[[:alnum:]]{4}' |
Line 458 get_exif_info()
|
Line 488 get_exif_info()
|
exifinfo="$exifinfo$exif " |
exifinfo="$exifinfo$exif " |
fi |
fi |
done |
done |
echo $exifinfo | 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 |
# parse args |
while [ "$1" != "" ] |
while [ "$1" != "" ] |
do |
do |
Line 522 do
|
Line 566 do
|
esac |
esac |
done |
done |
|
|
|
# go to gallery directory |
|
MY=$(get_my_path) |
|
cd "$ARG_DIR" || exit 1 |
|
|
# parese info file |
# parese info file |
if [ "$ARG_INFOFILE" != "" ] |
if [ "$ARG_INFOFILE" != "" ] |
then |
then |
Line 535 then
|
Line 583 then
|
done |
done |
fi |
fi |
|
|
# go to gallery directory |
|
MY=$(get_my_path) |
|
cd "$ARG_DIR" || exit 1 |
|
|
|
# fix url |
# fix url |
if [ "$ARG_URL" != "" ] |
if [ "$ARG_URL" != "" ] |
then |
then |
Line 570 echo
|
Line 614 echo
|
|
|
test $(echo $FLIST | wc -w) -eq 0 && err "error: no image found in \`\`$ARG_DIR''" |
test $(echo $FLIST | wc -w) -eq 0 && err "error: no image found in \`\`$ARG_DIR''" |
|
|
|
# use exif createtime to order images |
|
FLIST=$( |
|
( |
|
for file in $FLIST |
|
do |
|
echo "$(get_exif_ts $file) $file" |
|
done |
|
) | sort -n | awk '{print $2}' |
|
) |
|
|
# find new and to update images |
# find new and to update images |
FLIST_NEW= |
FLIST_NEW= |
FLIST_UPDATE= |
FLIST_UPDATE= |
Line 641 echo "tns: $targets" >> $MKAKEFILE
|
Line 695 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 |
|
all=$(echo $FLIST | wc -w) |
echo -n "create single html files " |
echo -n "create single html files " |
for file in $FLIST |
for file in $FLIST |
do |
do |
Line 651 do
|
Line 723 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 663 do
|
Line 740 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 $file $big $ARG_INDEX "$linkb" "$linkn" | html_img $file $i $all $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 |
|
|