Diff for /scripts/pgallery/src/pgallery.sh between versions 1.15 and 1.24

version 1.15, 2012/08/29 14:15:12 version 1.24, 2012/09/11 16:32:41
Line 1 Line 1
#!/bin/sh#!/home/as/sh
 #  #
 # THE BEER-WARE LICENSE 2012  # THE BEER-WARE LICENSE 2012
 # <as@paefchen.net> wrote this file. As long as you retain this notice you  # <as@paefchen.net> wrote this file. As long as you retain this notice you
 # 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.14 2012/08/29 13:36:01 as Exp $# $Paefchen: scripts/pgallery/src/pgallery.sh,v 1.23 2012/09/11 16:24:46 as Exp $
 #  #
   . $(dirname $0)/libpgallery
   
 ARG_TITLE="PGallery"  ARG_TITLE="PGallery"
 ARG_FILES=  ARG_FILES=
Line 24  ARG_MAILTO="" Line 25  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"  ARG_EXIF="0x920a 0x829d 0x829a ISO 0x8827 / 0x010f - 0x0110"
   ARG_INDEXIMG=
   ARG_STARTTS=
   ARG_ENDTS=
   ARG_LINK=
   ARG_NAVI=0
   
 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"  MKAKEFILE=".htmakefile"
 VERSION="pgallery-1.2"  
   
 #  #
 # usage()  # usage()
Line 42  usage() Line 40  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>] [-H <link>]
                 [-b <big_size>] [-c <big_quality>] [-l link] [-e <exif>]                  [-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] [-w] | -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)
Line 56  Options: Line 54  Options:
   -h            this page    -h            this page
   -i name       index file name (default: $ARG_INDEX)    -i name       index file name (default: $ARG_INDEX)
   -l url        gallery link    -l url        gallery link
     -m image      image for pgalleryindex. default the first image
   -n name       page title (default: $ARG_TITLE)    -n name       page title (default: $ARG_TITLE)
   -s suffix     list of suffix. if no \`\`-f'' defined, used to find images    -s suffix     list of suffix. if no \`\`-f'' defined, used to find images
                 in \`\`-d'' directoy. case insensitive                  in \`\`-d'' directoy. case insensitive
Line 63  Options: Line 62  Options:
   -t size       size from thumbnail images in pixel (default: $ARG_TNSIZE)    -t size       size from thumbnail images in pixel (default: $ARG_TNSIZE)
   -u quality    quality from thumbnail images 0-100% (default: $ARG_BIGQALITY)    -u quality    quality from thumbnail images 0-100% (default: $ARG_BIGQALITY)
   -v            print version    -v            print version
     -w            enable navi width link in the overview
   -C copyright  copyright (html) string (default: $ARG_COPYRIGHT)    -C copyright  copyright (html) string (default: $ARG_COPYRIGHT)
   -F from       mail sender (default: $ARG_MAILFROM)    -F from       mail sender (default: $ARG_MAILFROM)
     -L link       optional home link
   -I file       info text file for pgallery. info file paras prefered.    -I file       info text file for pgallery. info file paras prefered.
                 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                                    EXIF INDEXIMG LINK NAVI
   -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 77  USAGE Line 78  USAGE
         exit          exit
 }  }
   
## first find image dir
# get_my_path()is_dir=0
#for arg in $*
get_my_path()do
{        if [ $is_dir -eq 1 ]
        current=$(pwd) 
        cd $(dirname $0) 
        echo $(pwd)/$(basename $0) 
        cd "$current" 
} 
 
# 
# html_header() 
# 
html_header() 
{ 
        cat <<HTML 
<?xml version="1.0" encoding="utf-8"?> 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"> 
<head> 
        <title>$ARG_TITLE</title> 
        <meta http-equiv="content-type" content="text/html; charset=utf-8" /> 
        <style type="text/css"> 
        <!-- 
body { 
        background-color: #464646; 
        background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAFgAAABYB\ 
AMAAACDuy0HAAAAG1BMVEX+/v4BAQH///8KCgoDAwN/f3/19fWAgID8/PzhDwT2AAAACXRSTlMFBQUFBQU\ 
FBQWHDtP9AAALwklEQVR4Xg3KOWOyWhAA0Bn2ci57eXEvQY1JCZp8sQTjVoJLTAkaE0swbj/7ve4UB37FL\ 
W4q86Lwwlh86J/ASAkpWaj+Krbb31Hz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MSX1IaTeDmTRGEeK\ 
vAvtaaBaLQnjftGJz+4cjFyy6/iCjLGF2/gW+jQhEUxbEBPyQzXi+Bb4kc9wK4jIwNLWbwQAOtYKRLaipD\ 
H+X4TPPOG8DCNY4IC9yBk1qcibjhUgRnDcf35pl9d5otbvQjOIXlEu5dVtm5LRaK5KWcD/PX6LaGd25CuN\ 
HG/vgeIB1kcpCme+J8idlcjfBALAJSggznsGHGOAJgdGduMnZg+bAaeGASGV9bh/X2wPsVTmBLxmTTQsBG\ 
FkEOkZJTsGAm+HrtMDbWwvTXOutX1u7BxIq9Xib6DkFMbUitNdrYsULkahsAhBEh9FjdzL9BNARxTSr7T3\ 
u1rE+IWUmCIpwTZHZCu5l9THCuCcOhZqfekuQxjQ7EoyGUJAwCv/q1JOuJeCc/3lknb76zAquO/DAQhK/6\ 
2cP8X2s3+IBLIhvL8RHopoHpIArJysYTTmMMeubPXh8W760AvMVH67jqgg06+/ne5MZ631z6yROhloh3dP\ 
QirZoEpr80wgt/cEbhbAQTmRLtGh8lxCwDBBb5OeJ4aEq25XBNMT2rzWedW2zIzj+CCDKlnlyJBzT81qBW\ 
p69h7vlb3TmEV+DNm2rqj1iT7BQuwVVsuPkwq1e5P8tgNjVbIlMzwXeM11kZqjx3KKFOJzc3CAyFVhi8fx\ 
VZ5FvhdAM5mM6kS6OgKu16MFglq3/b/QVIwdw7HUCyeW04JPjC5dO+GC9OfqfB4VX+wwuift+ths2Ss3i6\ 
nkOE+JFyD+wKFL+WMX6nwwDva0S1/O8Mlnida69Ph96fuFvCoRMvXnCfsLPPmC/hA5RnMNE4fDK0pVOQ4B\ 
HLaErzv/wD99ABmjNZk0AAAAABJRU5ErkJggg=="); 
        margin: 10px auto; 
        font-family: Geneva,Arial,sans-serif; 
        font-size: 12px; 
        text-shadow: 1px 1px 1px #000; 
        color: #808080; 
} 
div.tn { 
        float: left; 
        width: ${ARG_TNSIZE}px; 
        height: ${ARG_TNSIZE}px; 
        vertical-align:text-top; 
        text-align: center; 
        margin: 4px; 
} 
div.tn a { 
        position: relative; 
        display: inline-block; 
        height: ${ARG_TNSIZE}px; 
} 
div.tn, div.big { 
        background-color: black; 
        border-width: 1px; 
        border-style: solid; 
        border-color: gray; 
        box-shadow: 1px 1px 2px #000; 
        padding: 1px; 
        border-radius: 3px; 
} 
div.tn:hover { 
        background-color: #222; 
} 
div.big { 
        display: inline-block; 
        width: ${ARG_BIGSIZE}px; 
} 
div.over { 
        width: ${ARG_BIGSIZE}px; 
        position: absolute; 
        top: 30px; 
        padding: 1px; 
} 
div.over a.left, div.over a.right { 
        display: block; 
        /* shell fuck of: missing CTLARI (shouldn't happen) - WTF?! */ 
        width: $(($ARG_BIGSIZE / 2))px; 
        position: relative; 
        top: 1px; 
        left: 1px; 
        background-repeat: no-repeat; 
} 
div.over a.left:hover { 
        background-position: 5% center; 
        background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAB0AAAAwC\ 
AYAAADtoXHnAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAh9JREFUeNrE2L1Lw0A\ 
UAHATSivSZii0ldpBnMU6SgYJpQUJDlk7dLV+LTqIiIv4B7kLolBKQRA6GLqUDMEhqKAlhUIR4125SHo0b\ 
XJ51x68pDSX+3G5I/dyguM4S/MuMfeHIAiQ7Yo+//+OocAYPm+jWEXxg8JC8erCgvt4AXrqgkkUJRRZ6jq\ 
G71EMRcAeil6wWq2uGYZx1ul0jjRNy5Jey6PauKcRJ5NIhklCoaE4QODNYDCwHVJ6vd5HIpE4xNdQxKOiM\ 
0G3FIvFc4Imo6CBQV3XXwioje5jREOBkiQdE3SLFWUFFXJfaJQVLP2DIWdvFDA+9pYKiMKBAVFYMAAKD85\ 
A+YBTUH6gD8oXnIDyB31QviCFzgekUPxYVe4ghW7ixhRFueQKUmgZN9hut1s0aNv2V6FQOAUBqRvT+IAaX\ 
6crWZb1hsqQJFfPkPnpJz6YpmnQlXK5XD6TycRIcrUDib7jQ71ev+v3+9/eSqlUKt1qtU4IvIFid2x9jDC\ 
muJE9PG6qql7jcaTHttvt6gh2J1MZYva6ees+d9jnjcQXnoDyh31WGb7wlPWUHzwjc+ADB8iR4OGA2SAsH\ 
CLvhYNDZvgwMMO3THSY8auNBS6xfrVFhZUoaGjYk+qA7DkEgmu12i1Bs1C7K1NhvLviecTLEOhEuFKpXDW\ 
bzcdGo/Egy/KFZzKJPHbMVsiEyVPXTRRPeMdMWMQuqLi0gPInwACOBcZx3lRFMwAAAABJRU5ErkJggg=="); 
} 
div.over a.right:hover { 
        background-position: 95% center; 
        background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAB0AAAAwC\ 
AYAAADtoXHnAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAiJJREFUeNrE2D1Lw0A\ 
YAOAmlNbBdii0FVM6OEu7SgcJpRUJDlk7dE21uuggIi7iD/IX+AGlFAXBDqVLyVCCBBW0JFhwMN7JHRxnY\ 
5PcnX3hhSM58nB3+Xhzkud5sf8OiWjLPn2+eGF4gHEChLkOcgUdt0E+isAlhCVAbiGQjGeQ1yBdHjAeKZ7\ 
SCgR1Xc8Nh8M90zQPG42GAo7lQFZBLhOzwSXgKI1kMrk7mUxePBTT6dQB8Dk8B1IHmUbTLrOMFI8WjsIol\ 
8tHHhW8YRKV0QWNwWDwIBKm0RK8aDqdbouEaRReQBUNkygJV0XCNBojnldh8CxUOOyHCoX/QoXB81AhcBC\ 
UOxwU5QqHQbnBYVFWODLKDEdFo8IanGYWNBSsquoJgkus6C+4UCgcOI7zRsP9fv8OoTWM8qh57mHlaFnWp\ 
23bFn1SUZQiambm1bphYgMWddlsNp7P51fpk+Px2ETNV1YUf383Qa5BsNfr7adSqQzZyXXd91ardUmUs8x\ 
rWYNrBcD2aDQa0GsJ11fTtDO0ntssd28UcAfXzSxvpLBg5DcSKyhH/cowgVG+p8xg2MqBCximRuIGBq0Gu\ 
YJB6l7u4LwKXwjo9y8jFPT7a6uKBGehqmiQRhO45BAJ0ijcQTGazeaFSJBGl/DUkrsrvMFZa/pzE1UqleN\ 
Op3PV7XZv6vX6KU+QRMkdM3gzFal+TyBvQX7w3DGTFrELKscWEN8CDADBm8pgcciwqgAAAABJRU5ErkJgg\ 
g==");  
} 
div.big a { 
        position: relative; 
        display: inline-block; 
        width: ${ARG_BIGSIZE}px; 
} 
div.box { 
        text-align: center; 
        width: ${ARG_BIGSIZE}px; 
        margin: auto; 
} 
div.box div.d { 
        width: ${ARG_BIGSIZE}px; 
        padding: 5px; 
        text-align: center; 
} 
div.box div.i { 
        width: ${ARG_BIGSIZE}px; 
        font-size: 90%; 
        height: 25px; 
        line-height: 25px; 
        position: relative; 
} 
body > div.c { 
        text-align: center; 
        font-size: 90%; 
        height: 25px; 
        line-height: 25px; 
        position: relative; 
        margin: 4px; 
} 
a img { 
        border-width: 0; 
} 
a { 
} 
div.nav { 
        width: ${ARG_BIGSIZE}px; 
        height: 20px; 
} 
div.nav a { 
        color: #FFF; 
        text-decoration: none; 
} 
div.nav a:hover { 
        text-decoration: underline; 
} 
div.nav div.top { 
        position: absolute; 
        text-align: center; 
        width: $(($ARG_BIGSIZE - 100))px; 
        margin: 0 50px; 
} 
.left { 
        float: left; 
} 
.right { 
        float: right; 
} 
.clear { 
        clear: both; 
} 
                --> 
                </style> 
        </head> 
<body> 
HTML 
} 
 
# 
# html_footer() 
# 
html_footer() 
{ 
        cat <<HTML 
</body></html> 
HTML 
} 
 
# 
# html_tn() 
# 
html_tn() 
{ 
        tn=$1 
        link=$2 
 
        info=$($BIN_IMGINFO -f $tn) 
        width=$(echo $info | awk '{print $3}') 
        height=$(echo $info | awk '{print $4}') 
        top=$(($(($ARG_TNSIZE - $height)) / 2)) 
 
        cat <<HTML 
<div class="tn"> 
        <a href="$link" style="top:${top}px"> 
                <img alt="$tn" width="$width" height="$height" src="$tn" /> 
        </a> 
</div> 
HTML 
} 
 
# 
# html_img() 
# 
html_img() 
{ 
        orig=$1 
        num=$2 
        all=$3 
        img=$4 
        link=$5 
        linkb=$6 
        linkn=$7 
 
        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          then
                desc="<div class='d'>$desc</div>"                ARG_DIR="$arg"
                 break
         fi          fi
           test $arg = -d && is_dir=1
   done
   
        if [ "$linkb" != "" ]# load save args
        thenif [ -f "$ARG_DIR/$ARGFILE" ]
                hlinkb="<a href='$linkb'>prev</a>"then
                olinkb="<a class='left' style='height:${height}px' href='$linkb'></a>"        echo "load save settings"
        fi        . "$ARG_DIR/$ARGFILE"
 fi
   
         if [ "$linkn" != "" ]  
         then  
                 hlinkn="<a href="$linkn">next</a>"  
                 olinkn="<a class='right' style='height:${height}px' href='$linkn'></a>"  
         fi  
   
         cat <<HTML  
 <div class="box">  
         <div class="nav">  
                 <div class="top">  
                         <a href="$link">index</a>&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;<a href="$orig">original</a>&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;$num/$all  
                 </div>  
                 <div class="left">$hlinkb</div>  
                 <div class="right">$hlinkn</div>  
         </div>  
         <div class="big">  
                 <img alt="$img" width="$width" height="$height" src="$img" />  
         </div>  
         $desc  
         <div class="i">  
                 <div class="left">$(get_exif_info $orig)</div>  
                 <div class="right">$ARG_TITLE $ARG_COPYRIGHT</div>  
         </div>  
         <div class="over" style='height:${height}px'>  
                 $olinkb  
                 $olinkn  
         </div>  
 </div>  
 HTML  
 }  
   
 #  
 # err  
 #  
 err()  
 {  
         echo "$1" >&2  
         exit 1  
 }  
   
 #  
 # mysendmail()  
 #  
 mysendmail()  
 {  
         subject=$1  
         (  
                 cat <<MAIL  
 From: $ARG_MAILFROM  
 To: $ARG_MAILTO  
 Subject: $subject  
 Content-Type: text/plain; charset=iso-8859-1  
 X-Mailer: $VERSION  
   
 $(cat)  
 MAIL  
         ) | $BIN_SENDMAIL -t  
 }  
   
 #  
 # get_exif_desc()  
 #  
 get_exif_desc()  
 {  
         img=$1  
         $BIN_EXIF --ifd=0 --tag=0x010e -m $img 2> /dev/null | while read line  
         do  
                 echo "$line<br />"  
         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()  
 {  
         img=$1  
         hex=$2  
         $BIN_EXIFTRAN -d $img | grep $hex | sed -E 's/^.{45}//'  
 }  
   
 #  
 # get_exif_info()  
 #  
 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}'  
                 then  
                         exifinfo="$exifinfo$(get_exif_value $img $exif) "  
                 else  
                         exifinfo="$exifinfo$exif "  
                 fi  
         done  
         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 550  do Line 141  do
                 -F)                  -F)
                         ARG_MAILFROM=$1                          ARG_MAILFROM=$1
                         shift;;                          shift;;
                   -L)
                           ARG_LINK=$1
                           shift;;
                 -I)                  -I)
                         ARG_INFOFILE=$1                          ARG_INFOFILE=$1
                         shift;;                          shift;;
Line 561  do Line 155  do
                 -v)                  -v)
                         echo $VERSION                          echo $VERSION
                         exit;;                          exit;;
                   -w)
                           ARG_NAVI=1;;
                 *)                  *)
                         echo "unknown argument $arg"                          echo "unknown argument $arg"
                         exit                          exit
Line 576  if [ "$ARG_INFOFILE" != "" ] Line 172  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 EXIF                BIGQALITY MAILTO MAILFROM URL EXIF INDEXIMG LINK NAVI
         do          do
                 v=$(make -f $ARG_INFOFILE -V$n)                  v=$(make -f $ARG_INFOFILE -V$n)
                 test "$v" = "" && continue                  test "$v" = "" && continue
Line 584  then Line 180  then
         done              done    
 fi  fi
   
# paras from iso to utf-8#paras from iso to utf-8
 for n in $(set | awk -F= '{print $1}')  for n in $(set | awk -F= '{print $1}')
 do  do
         echo "$n" | grep -q '^ARG_' || continue          echo "$n" | grep -q '^ARG_' || continue
        eval "$n=\"\$(echo \"\$$n\" | iconv -f ISO-8859-1 -t UTF-8)\""        eval "$n=\"\$(echo \"\$$n\" | $BIN_ICONV -f ISO-8859-1 -t UTF-8)\""
 done  done
   
 # fix url  # fix url
Line 606  then Line 202  then
                 match="$match *.$(echo $type | tr '[:lower:]' '[:upper:]')"                  match="$match *.$(echo $type | tr '[:lower:]' '[:upper:]')"
                 match="$match *.$(echo $type | tr '[:upper:]' '[:lower:]')"                  match="$match *.$(echo $type | tr '[:upper:]' '[:lower:]')"
         done          done
        ARG_FILES=$(cd $ARG_DIR && ls $match 2>/dev/null)        FLIST=$(ls $match 2>/dev/null)
 else
         FLIST="$ARG_FILES"
 fi  fi
   
# Filter big and thumbnails# Filter big, thumbnails and curipted images
 echo -n "find images"  echo -n "find images"
FLIST=FLISTF=
for file in $ARG_FILESfor file in $FLIST
 do  do
         test $(echo $file | grep -E '\.(tn|big)\.jpg$') && continue          test $(echo $file | grep -E '\.(tn|big)\.jpg$') && continue
        FLIST="$FLIST $file"        test $($BIN_JPEGINFO $file | grep -Eq 'WARNING|ERROR') && continue
         FLISTF="$FLISTF $file"
         echo -n " $file"          echo -n " $file"
 done  done
echo echo
 FLIST="$FLISTF"
   
 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''"
   
Line 632  FLIST=$( Line 232  FLIST=$(
         ) | sort -n | awk '{print $2}'          ) | sort -n | awk '{print $2}'
 )  )
   
   # if no master image, we use the first one
   test "$ARG_INDEXIMG" = "" && ARG_INDEXIMG=$(echo $FLIST | awk '{print $1}')
   
   # find start and end ts
   ARG_STARTTS=$(get_exif_ts $(echo $FLIST | awk '{print $1}'))
   ARG_ENDTS=$(get_exif_ts $(echo $FLIST | awk '{print $NF}'))
   
 # find new and to update images  # find new and to update images
 FLIST_NEW=  FLIST_NEW=
 FLIST_UPDATE=  FLIST_UPDATE=
Line 658  echo "tns: $targets" >> $MKAKEFILE Line 265  echo "tns: $targets" >> $MKAKEFILE
 FLIST_UPDATE=$(make -f $MKAKEFILE)  FLIST_UPDATE=$(make -f $MKAKEFILE)
 rm $MKAKEFILE  rm $MKAKEFILE
   
   # save args
   test -f $ARGFILE && rm $ARGFILE
   echo "save settings"
   set | while read n
   do
           echo "$n" | grep -q '^ARG_' || continue
           echo "$n" | grep -q '^ARG_UPDATE' && continue
           echo "$n" >> $ARGFILE
   done
   
 # update and no new and update images found  # update and no new and update images found
 if [ $ARG_UPDATE -eq 1 -a "$FLIST_NEW" = "" -a "$FLIST_UPDATE" = "" ]  if [ $ARG_UPDATE -eq 1 -a "$FLIST_NEW" = "" -a "$FLIST_UPDATE" = "" ]
 then  then
Line 700  MAKE Line 317  MAKE
 done  done
 echo "tns: $targets" >> $MKAKEFILE  echo "tns: $targets" >> $MKAKEFILE
   
#make -f $MKAKEFILEmake -f $MKAKEFILE
 rm $MKAKEFILE  rm $MKAKEFILE
   
 # create html index  # 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  echo create html index
 (  (
         html_header          html_header
        echo $index
         startdate=
         test $ARG_STARTTS -ne -1 && startdate=$(date -r $ARG_STARTTS "+%d.%m.%Y")
         enddate=
         test $ARG_ENDTS -ne -1 && enddate=$(date -r $ARG_ENDTS "+%d.%m.%Y")
         date=
         test "$startdate" != "" && date="$startdate"
         test "$enddate" != "$startdate" && date="$date - $enddate"
         link=
         test "$ARG_LINK" != "" && link="<a href='$ARG_LINK'>overview</a>"
         html_title "$ARG_TITLE" "$link" "$date"
 
         for file in $FLIST
         do
                 tn="${file}.tn.jpg"
                 imglink="${file}.html"
                 html_tn $tn $imglink
         done
         echo "<div class='clear'></div>"          echo "<div class='clear'></div>"
         echo "<div class='c'>$ARG_TITLE $ARG_COPYRIGHT</div>"          echo "<div class='c'>$ARG_TITLE $ARG_COPYRIGHT</div>"
         html_footer          html_footer
 ) > $ARG_INDEX  ) > $ARG_INDEX
   
 # create single html files  # create single html files
 #test $ARG_UPDATE -eq 1 && FLIST="$FLIST_NEW $FLIST_UPDATE"  
 i=0  i=0
 all=$(echo $FLIST | wc -w)  all=$(echo $FLIST | wc -w)
 echo -n "create single html files "  echo -n "create single html files "

Removed from v.1.15  
changed lines
  Added in v.1.24