version 1.11, 2012/08/29 11:21:41
|
version 1.17, 2012/08/29 14:44:04
|
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.10 2012/08/29 10:52:35 as Exp $ | # $Paefchen: scripts/pgallery/src/pgallery.sh,v 1.16 2012/08/29 14:15:50 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.2" | VERSION="pgallery-1.3" |
|
|
# |
# |
# usage() |
# usage() |
Line 94 get_my_path()
|
Line 94 get_my_path()
|
html_header() |
html_header() |
{ |
{ |
cat <<HTML |
cat <<HTML |
|
<?xml version="1.0" encoding="utf-8"?> |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" |
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
<html xmlns="http://www.w3.org/1999/xhtml"> |
<html xmlns="http://www.w3.org/1999/xhtml"> |
<head> |
<head> |
<title>$ARG_TITLE</title> |
<title>$ARG_TITLE</title> |
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" /> | <meta http-equiv="content-type" content="text/html; charset=utf-8" /> |
<style type="text/css"> | <style type="text/css"> |
<!-- | <!-- |
body { |
body { |
background-color: #464646; |
background-color: #464646; |
background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAFgAAABYB\ |
background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAFgAAABYB\ |
Line 256 div.box div.i {
|
Line 257 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 342 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 361 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 426 MAIL
|
Line 430 MAIL
|
get_exif_desc() |
get_exif_desc() |
{ |
{ |
img=$1 |
img=$1 |
$BIN_EXIF --ifd=0 --tag=0x010e -m $img 2> /dev/null | iconv -t ISO-8859-1 -f UTF-8 | while read line | $BIN_EXIF --ifd=0 --tag=0x010e -m $img 2> /dev/null | while read line |
do |
do |
echo "$line<br />" |
echo "$line<br />" |
done |
done |
} |
} |
|
|
# |
# |
|
# 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 476 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 489 get_exif_info()
|
exifinfo="$exifinfo$exif " |
exifinfo="$exifinfo$exif " |
fi |
fi |
done |
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/ se(c|k)./s/' -e 's/ ISO / ISO/' -e 's/ ISO(\/| )/ \1/' |
} |
} |
|
|
# |
# |
Line 536 do
|
Line 567 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 549 then
|
Line 584 then
|
done |
done |
fi |
fi |
|
|
# go to gallery directory | # paras from iso to utf-8 |
MY=$(get_my_path) | for n in $(set | awk -F= '{print $1}') |
cd "$ARG_DIR" || exit 1 | do |
| echo "$n" | grep -q '^ARG_' || continue |
| eval "$n=\"\$(echo \"\$$n\" | iconv -f ISO-8859-1 -t UTF-8)\"" |
| done |
|
|
# fix url |
# fix url |
if [ "$ARG_URL" != "" ] |
if [ "$ARG_URL" != "" ] |
Line 584 echo
|
Line 622 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 675 echo create html index
|
Line 723 echo create html index
|
# create single html files |
# create single html files |
#test $ARG_UPDATE -eq 1 && FLIST="$FLIST_NEW $FLIST_UPDATE" |
#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 701 do
|
Line 750 do
|
echo -n . |
echo -n . |
( |
( |
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 |
|
|
|
# .htaccess |
|
if [ -f .htaccess ] |
|
then |
|
grep -q 'AddCharset UTF-8 .html' < .htaccess || echo "AddCharset UTF-8 .html" >> .htaccess |
|
else |
|
echo "AddCharset UTF-8 .html" > .htaccess |
|
fi |
|
|
test "$ARG_MAILTO" = "" && exit 0 |
test "$ARG_MAILTO" = "" && exit 0 |
|
|