Annotation of scripts/pgallery/src/libpgallery.sh, revision 1.6

1.1       as          1: #!/bin/sh
                      2: #
1.6     ! as          3: # THE BEER-WARE LICENSE 2012,13
        !             4: #
1.1       as          5: # <as@paefchen.net> wrote this file. As long as you retain this notice you
                      6: # can do whatever you want with this stuff. If we meet some day, and you think
                      7: # this stuff is worth it, you can buy me a beer in return Aron Schlesinger
                      8: #
1.6     ! as          9: # $Paefchen: scripts/pgallery/src/libpgallery.sh,v 1.5 2012/09/11 16:24:46 as Exp $
1.1       as         10: #
                     11: 
                     12: BIN_CONVERT="/usr/local/bin/convert"
                     13: BIN_EXIFAUTOTRAN="/usr/local/bin/exifautotran"
                     14: BIN_IMGINFO="/usr/local/bin/imginfo"
                     15: BIN_SENDMAIL="/usr/sbin/sendmail"
                     16: BIN_EXIFTRAN="/usr/local/bin/exiftran"
                     17: BIN_EXIF="/usr/local/bin/exif"
1.5       as         18: BIN_JPEGINFO="/usr/local/bin/jpeginfo"
                     19: BIN_ICONV="/usr/local/bin/iconv"
1.1       as         20: 
                     21: ARGFILE=".htpgallery"
1.5       as         22: VERSION="pgallery-1.4"
1.1       as         23: 
                     24: #
                     25: # get_my_path()
                     26: #
                     27: get_my_path()
                     28: {
                     29:        current=$(pwd)
                     30:        cd $(dirname $0)
                     31:        echo $(pwd)/$(basename $0)
                     32:        cd "$current"
                     33: }
                     34: 
                     35: #
                     36: # html_header()
                     37: #
                     38: html_header()
                     39: {
                     40:        cat <<HTML
                     41: <?xml version="1.0" encoding="utf-8"?>
                     42: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
                     43:        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
                     44: <html xmlns="http://www.w3.org/1999/xhtml">
                     45: <head>
                     46:        <title>$ARG_TITLE</title>
                     47:        <meta http-equiv="content-type" content="text/html; charset=utf-8" />
                     48:        <style type="text/css">
                     49:        <!--
                     50: body {
                     51:        background-color: #464646;
                     52:        background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAFgAAABYB\
                     53: AMAAACDuy0HAAAAG1BMVEX+/v4BAQH///8KCgoDAwN/f3/19fWAgID8/PzhDwT2AAAACXRSTlMFBQUFBQU\
                     54: FBQWHDtP9AAALwklEQVR4Xg3KOWOyWhAA0Bn2ci57eXEvQY1JCZp8sQTjVoJLTAkaE0swbj/7ve4UB37FL\
                     55: W4q86Lwwlh86J/ASAkpWaj+Krbb31HzH0Kjc2tIl7SADaWbpZBPE5dds6jJNyNdjAyKWqdroIixWRQIY6E\
                     56: /kOY7hIciL/ZfrAO3XP/06AuUJ3mSd/z95OB9vIal0DPlaZWHP7RE6DIXjmKqKkuGr+xNZylOnj1GSlUKv\
                     57: nxZDBOIzTfMe0fJgJ7c/GIIOdUuKxYyBFUOzvY6AC5AXx8R+o5O4S0j0wqBND3ErIYm/XHFbQjtH1MXD5d\
                     58: Ubp19OFdjkDlys+HSwrBgHRvL9wVN/pi8ViOIwcv/D1GRW6UuDvJLLQA5lCI17iUdsKYpOuYfMATGnpn/Z\
                     59: s3W6gov51G+/Vs9Ay//we5kh8uwvEPum6o5HkDMDb3ZWunwtq+UzENU8NphDdbvNtKM3knx5gi6UMSQl+e\
                     60: Gs+27mraDtxeWdH+T62Us/GylEtr7Ct8jlbeXKvAf5onx8D2uVt1J/GblV+XQyKUInOUG44fqjcszK266y\
                     61: HWAAYG9ekhvy4l4Maa44jYVyV2RFEuS54e2HcswtmNdqR/+V4P0O9e4XnpWgxVSQkNXpYMCxJ4Vel0lmi5\
                     62: 6jnYIIJAQMndF+zTEiyuj92r3ijJT1O0alPQnLWJvJLR7Xx7Xg9fm9QOqFu8o29m3QQqFwZN4bki/RoprN\
                     63: tMKKtEET9iMsJyKpkiguAorn2yzkv0wG3M1EEVDJP5VN7muLjYCglzdGQ7boYGgRmorzhRDq83gglgylC+\
                     64: hBLEyy6ZQWNwCmmqt6PvExAqGEA9V2XIT4/fS+I2cx1n5td85kOCjHfPWTg72FJ/+vKOyggt+rytFbEDJW\
                     65: L+mPwpgw6HtFLIHmq4o2m1nZ9saKwiKEOTVZtWlnqHODPu949VfKD+zzpfynd/ZZU5IWZ0dgnqRHC4uOBp\
                     66: BsT8N7YbFJzADiW2eo/T979OKFxY8zk/+HR/NNEkzgSBsmA35Sayz1m/ubxgmYQOmffyRh9gdx42mUVX51\
                     67: 2oqWkfxAzyuSCxx1cywx3jIXuXJEEbssymo0xMy7SskJW9C5IPYroPwQunt7f5FEPPXJLWRbGHcL4Q3sx3\
                     68: TLAN6W672r/I5CKkL6zSwwk0AI8+iBCSv1Y7QQP5RSoLE227uy8vn22Y6dhLBgEsRh18cTGjIv3y+60Kmt\
                     69: 3YAZQX8qf3bJDUc/5pdjti+KwAZ9GzzQzd23d1JBAnSvWkWB8YfsIGlspHitNiMPYPFfR+OecRuPyxgfoP\
                     70: 9/HkR3cR27IohiaDXCk/3VNP6lIxP9TBnsMeAAUZloq6P8KURLBsNFuiA3LsN/d9qpCeKKIBgSzsN5k+rd\
                     71: h3uh0VbvMuOIomJD1fBOiCqIsvklS5bOQhMaahJC+Rc+6lz+Uvxmq05Py+LoGIQlLKvlcaHsFG9Ui66H/q\
                     72: dHz67sPRGho+ruC92QgN5JEMmLsZREEiJu78FJbyzT8FsdK90XoEcezn2R5iLUzZhczJmf1yNY3gJNJUQv\
                     73: bpTznTAbnV5J8iL4q2OWuhJEndWVTyEr8M5VGTWtvOmUo1DsnOsqXE5ZzKE8K4/8cl8+c1XArp1RUKz+iK\
                     74: P96j2FcUmA+v0HnEr0iUdSrRK5duAj1FQamvpiaXR2JddD6g8n4SyFx/fjT4LkC+ghJckj1e1wP+DrHrpI\
                     75: iMaPH5F1rcaRvwZWfEn6fx+/C7PdXABGLNKjr1USZ5XyHjsafXMEoXtguAfjykMioMMHISXVAc9yQY5o5Q\
                     76: g8MM0nhWCA2HoiEgBc1EH+warLjxH3Ln68M/ciFqI1bG0mBOxiNreOuShEf/9pIzhm1Bh2cbYVxn2IYQ7e\
                     77: ljYpab/5EdPF2PSmcy+62j6e2HBPNbe+8JVMuRQBrWdL9uBh4bYbQaQJ07FyfcpCuvSuxUyYjP6avvw9gT\
                     78: cAj0uTVohSwOHDDaHTs8nyachMBcWoVDWp3/lWgqeCLMneAUhSuhD2RJpufLOSi7emxOVhYsOGomV2JCEK\
                     79: jWu7kuqwueyFEmDgVhR0l4oHn8W87UZuxb8id54SxHWiSnPKnMyAhzdhi2wN/AoH3OYwLajuybB8h/QeJJ\
                     80: iX1gIt+dfij+gr0CJRXQ2Y04Q6q8xHzfWm9FIgchiW0+X86tIotIGzRG1gENaKokQkLn+FXZ2x3KUcp7d/\
                     81: NUsmOmFCG/i03YB8pi0eiNS4LUIfA06AKvfQmP/VAXS1AP2kzJ+9LAaTafvFyO7bz8U9OCpld2q1eHGts+\
                     82: ZFrt04AmIlubOPP7Xayfi/r0tiX2aaPT9Dz4+TVPBoXsjHDzWfrmawOsZfmBT/k2+c6sz/hvD5wjrjT7Xg\
                     83: RlnEzPuZermi1jqfUrE3q7VdFfJu5oT9Ad+VUh1fIwIFhBy8TmMuhIeX2XpmogmvS1C3ZuwiyR87ZSrj0J\
                     84: v1DpEAYkbcL3RpjZXmZpPV4mXH8z8Nh8CS+R+PpcTnkhyr5UJaSiz0wjK22Ewl+zS+pTug0PQ0CSnJQ5Lf\
                     85: dR77vVZufgjkQ/ydf4V5zpEaNq+JZmrQK6WdZBacmMHL9RmLnPUs0/MYwYFzoyrXYQMTHGAUJOfumR5r79\
                     86: MZO28DIEXQVT5wGw99TY1T0GOCC/BzWv8READwICd0LjUNKnE6ORVa0lOnqhoO0v33lwWcwF0ynTgTpFxy\
                     87: +0OKdphNDWJlH8ubKoG6WJXtKxAwbsilpBJB+GBwimvTsCrv1R7LSX9ExkAw44ZEcxU3L50OHnKAyKZNe1\
                     88: fih+hVqItRGCDf7shuvme+lTWteX5oYuc58NrCaqjYIrIV0PFyQeh2ZzZEqNS60LuhnP5wweMkkaU93pDA\
                     89: /RWPNeGpPCBgiUeDvV0L1NfdRP/Hn5i7rUK7kftlIWeIUIYbtzzFl9nlIeaNfoX+x/qyWzIABLTZDbeq/h\
                     90: DZpxg2gkh+ICfSU8OUpJ8yWY17uQ5EGa+GGWFmnrBd9vX3KOteYkJaMpPwJ4TjzDjbhkOMKmWKClzVJ2g8\
                     91: 1YGFl/c0xPIKncgJGdUKvZoUUJu0gYaIAh6E0xNeQ15qpJXzNITgf4W+w/oUaKOM54EMUi1j5yvOCsEe8J\
                     92: YpwVGj53lNiPMY9Rltgd4icp82fvN69zkSBUI40nJSRTeHz7h1IX42Cr0klWjxjO05MSX1IaTeDmTRGEeK\
                     93: vAvtaaBaLQnjftGJz+4cjFyy6/iCjLGF2/gW+jQhEUxbEBPyQzXi+Bb4kc9wK4jIwNLWbwQAOtYKRLaipD\
                     94: H+X4TPPOG8DCNY4IC9yBk1qcibjhUgRnDcf35pl9d5otbvQjOIXlEu5dVtm5LRaK5KWcD/PX6LaGd25CuN\
                     95: HG/vgeIB1kcpCme+J8idlcjfBALAJSggznsGHGOAJgdGduMnZg+bAaeGASGV9bh/X2wPsVTmBLxmTTQsBG\
                     96: FkEOkZJTsGAm+HrtMDbWwvTXOutX1u7BxIq9Xib6DkFMbUitNdrYsULkahsAhBEh9FjdzL9BNARxTSr7T3\
                     97: u1rE+IWUmCIpwTZHZCu5l9THCuCcOhZqfekuQxjQ7EoyGUJAwCv/q1JOuJeCc/3lknb76zAquO/DAQhK/6\
                     98: 2cP8X2s3+IBLIhvL8RHopoHpIArJysYTTmMMeubPXh8W760AvMVH67jqgg06+/ne5MZ631z6yROhloh3dP\
                     99: QirZoEpr80wgt/cEbhbAQTmRLtGh8lxCwDBBb5OeJ4aEq25XBNMT2rzWedW2zIzj+CCDKlnlyJBzT81qBW\
                    100: p69h7vlb3TmEV+DNm2rqj1iT7BQuwVVsuPkwq1e5P8tgNjVbIlMzwXeM11kZqjx3KKFOJzc3CAyFVhi8fx\
                    101: VZ5FvhdAM5mM6kS6OgKu16MFglq3/b/QVIwdw7HUCyeW04JPjC5dO+GC9OfqfB4VX+wwuift+ths2Ss3i6\
                    102: nkOE+JFyD+wKFL+WMX6nwwDva0S1/O8Mlnida69Ph96fuFvCoRMvXnCfsLPPmC/hA5RnMNE4fDK0pVOQ4B\
                    103: HLaErzv/wD99ABmjNZk0AAAAABJRU5ErkJggg==");
                    104:        margin: 10px auto;
                    105:        font-family: Geneva,Arial,sans-serif;
                    106:        font-size: 12px;
                    107:        text-shadow: 1px 1px 1px #000;
                    108:        color: #808080;
                    109: }
                    110: div.tn {
                    111:        float: left;
                    112:        width: ${ARG_TNSIZE}px;
                    113:        vertical-align:text-top;
                    114:        text-align: center;
                    115:        margin: 4px;
                    116: }
                    117: div.t {
                    118:        text-overflow: ellipsis;
                    119:        overflow: hidden;
                    120:        white-space: nowrap;
                    121:        margin-bottom: 1px;
                    122:        background: rgb(38,38,38); /* Old browsers */
                    123:        background: -moz-linear-gradient(top, rgba(38,38,38,1) 0%, rgba(53,53,53,1) 50%, rgba(48,48,48,1) 51%, rgba(73,73,73,1) 100%); /* FF3.6+ */
                    124:        background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(38,38,38,1)), color-stop(50%,rgba(53,53,53,1)), color-stop(51%,rgba(48,48,48,1)), color-stop(100%,rgba(73,73,73,1))); /* Chrome,Safari4+ */
                    125:        background: -webkit-linear-gradient(top, rgba(38,38,38,1) 0%,rgba(53,53,53,1) 50%,rgba(48,48,48,1) 51%,rgba(73,73,73,1) 100%); /* Chrome10+,Safari5.1+ */
                    126:        background: -o-linear-gradient(top, rgba(38,38,38,1) 0%,rgba(53,53,53,1) 50%,rgba(48,48,48,1) 51%,rgba(73,73,73,1) 100%); /* Opera 11.10+ */
                    127:        background: -ms-linear-gradient(top, rgba(38,38,38,1) 0%,rgba(53,53,53,1) 50%,rgba(48,48,48,1) 51%,rgba(73,73,73,1) 100%); /* IE10+ */
                    128:        background: linear-gradient(to bottom, rgba(38,38,38,1) 0%,rgba(53,53,53,1) 50%,rgba(48,48,48,1) 51%,rgba(73,73,73,1) 100%); /* W3C */
                    129:        filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#262626', endColorstr='#494949',GradientType=0 ); /* IE6-9 */
                    130: }
1.2       as        131: div.tn div.t {
                    132:        width: $(($ARG_TNSIZE - 8))px;
                    133:        height: 20px;
                    134:        padding: 0 4px;
                    135:        line-height: 18px;
                    136: }
                    137: body > div.t {
                    138:        font-weight: bold;
                    139:        position: relative;
                    140:        bottom: 10px;
                    141:        padding: 6px;
                    142:        border-width: 0 0 1px 0;
                    143:        border-color: gray;
                    144:        border-style: solid;
1.3       as        145:        box-shadow: 1px 1px 2px #000000;
                    146:        margin-bottom: -6px;
1.5       as        147:        display: $(test $ARG_NAVI -eq 1 && echo block || echo none);
1.3       as        148: }
                    149: body > div.t div.center {
                    150:        position: absolute;
                    151:        text-align: center;
                    152:        top: 0px;
                    153:        padding: 6px;
                    154:        width: 100%;
1.2       as        155: }
1.1       as        156: div.tn a {
                    157:        position: relative;
                    158:        display: inline-block;
                    159:        height: ${ARG_TNSIZE}px;
                    160: }
                    161: div.tn, div.big {
                    162:        background-color: black;
                    163:        border-width: 1px;
                    164:        border-style: solid;
                    165:        border-color: gray;
                    166:        box-shadow: 1px 1px 2px #000;
                    167:        padding: 1px;
                    168:        border-radius: 3px;
                    169: }
                    170: div.tn:hover {
                    171:        background-color: #222;
                    172: }
                    173: div.big {
                    174:        display: inline-block;
                    175:        width: ${ARG_BIGSIZE}px;
                    176: }
                    177: div.over {
                    178:        width: ${ARG_BIGSIZE}px;
                    179:        position: absolute;
                    180:        top: 30px;
                    181:        padding: 1px;
                    182: }
                    183: div.over a.left, div.over a.right {
                    184:        display: block;
                    185:        /* shell fuck of: missing CTLARI (shouldn't happen) - WTF?! */
                    186:        width: $(($ARG_BIGSIZE / 2))px;
                    187:        position: relative;
                    188:        top: 1px;
                    189:        left: 1px;
                    190:        background-repeat: no-repeat;
                    191: }
                    192: div.over a.left:hover {
                    193:        background-position: 5% center;
                    194:        background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAB0AAAAwC\
                    195: AYAAADtoXHnAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAh9JREFUeNrE2L1Lw0A\
                    196: UAHATSivSZii0ldpBnMU6SgYJpQUJDlk7dLV+LTqIiIv4B7kLolBKQRA6GLqUDMEhqKAlhUIR4125SHo0b\
                    197: XJ51x68pDSX+3G5I/dyguM4S/MuMfeHIAiQ7Yo+//+OocAYPm+jWEXxg8JC8erCgvt4AXrqgkkUJRRZ6jq\
                    198: G71EMRcAeil6wWq2uGYZx1ul0jjRNy5Jey6PauKcRJ5NIhklCoaE4QODNYDCwHVJ6vd5HIpE4xNdQxKOiM\
                    199: 0G3FIvFc4Imo6CBQV3XXwioje5jREOBkiQdE3SLFWUFFXJfaJQVLP2DIWdvFDA+9pYKiMKBAVFYMAAKD85\
                    200: A+YBTUH6gD8oXnIDyB31QviCFzgekUPxYVe4ghW7ixhRFueQKUmgZN9hut1s0aNv2V6FQOAUBqRvT+IAaX\
                    201: 6crWZb1hsqQJFfPkPnpJz6YpmnQlXK5XD6TycRIcrUDib7jQ71ev+v3+9/eSqlUKt1qtU4IvIFid2x9jDC\
                    202: muJE9PG6qql7jcaTHttvt6gh2J1MZYva6ees+d9jnjcQXnoDyh31WGb7wlPWUHzwjc+ADB8iR4OGA2SAsH\
                    203: CLvhYNDZvgwMMO3THSY8auNBS6xfrVFhZUoaGjYk+qA7DkEgmu12i1Bs1C7K1NhvLviecTLEOhEuFKpXDW\
                    204: bzcdGo/Egy/KFZzKJPHbMVsiEyVPXTRRPeMdMWMQuqLi0gPInwACOBcZx3lRFMwAAAABJRU5ErkJggg==");
                    205: }
                    206: div.over a.right:hover {
                    207:        background-position: 95% center;
                    208:        background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAB0AAAAwC\
                    209: AYAAADtoXHnAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAiJJREFUeNrE2D1Lw0A\
                    210: YAOAmlNbBdii0FVM6OEu7SgcJpRUJDlk7dE21uuggIi7iD/IX+AGlFAXBDqVLyVCCBBW0JFhwMN7JHRxnY\
                    211: 5PcnX3hhSM58nB3+Xhzkud5sf8OiWjLPn2+eGF4gHEChLkOcgUdt0E+isAlhCVAbiGQjGeQ1yBdHjAeKZ7\
                    212: SCgR1Xc8Nh8M90zQPG42GAo7lQFZBLhOzwSXgKI1kMrk7mUxePBTT6dQB8Dk8B1IHmUbTLrOMFI8WjsIol\
                    213: 8tHHhW8YRKV0QWNwWDwIBKm0RK8aDqdbouEaRReQBUNkygJV0XCNBojnldh8CxUOOyHCoX/QoXB81AhcBC\
                    214: UOxwU5QqHQbnBYVFWODLKDEdFo8IanGYWNBSsquoJgkus6C+4UCgcOI7zRsP9fv8OoTWM8qh57mHlaFnWp\
                    215: 23bFn1SUZQiambm1bphYgMWddlsNp7P51fpk+Px2ETNV1YUf383Qa5BsNfr7adSqQzZyXXd91ardUmUs8x\
                    216: rWYNrBcD2aDQa0GsJ11fTtDO0ntssd28UcAfXzSxvpLBg5DcSKyhH/cowgVG+p8xg2MqBCximRuIGBq0Gu\
                    217: YJB6l7u4LwKXwjo9y8jFPT7a6uKBGehqmiQRhO45BAJ0ijcQTGazeaFSJBGl/DUkrsrvMFZa/pzE1UqleN\
                    218: Op3PV7XZv6vX6KU+QRMkdM3gzFal+TyBvQX7w3DGTFrELKscWEN8CDADBm8pgcciwqgAAAABJRU5ErkJgg\
                    219: g=="); 
                    220: }
                    221: div.big a {
                    222:        position: relative;
                    223:        display: inline-block;
                    224:        width: ${ARG_BIGSIZE}px;
                    225: }
                    226: div.box {
                    227:        text-align: center;
                    228:        width: ${ARG_BIGSIZE}px;
                    229:        margin: auto;
                    230: }
                    231: div.box div.d {
                    232:        width: ${ARG_BIGSIZE}px;
                    233:        padding: 5px;
                    234:        text-align: center;
                    235: }
                    236: div.box div.i {
                    237:        width: ${ARG_BIGSIZE}px;
                    238:        font-size: 90%;
                    239:        height: 25px;
                    240:        line-height: 25px;
                    241:        position: relative;
                    242: }
                    243: body > div.c {
                    244:        text-align: center;
                    245:        font-size: 90%;
                    246:        height: 25px;
                    247:        line-height: 25px;
                    248:        position: relative;
                    249:        margin: 4px;
                    250: }
                    251: a img {
                    252:        border-width: 0;
                    253: }
                    254: a {
                    255: }
                    256: div.nav {
                    257:        width: ${ARG_BIGSIZE}px;
                    258:        height: 20px;
                    259: }
1.3       as        260: a {
1.1       as        261:        color: #FFF;
                    262:        text-decoration: none;
                    263: }
1.3       as        264: a:hover {
1.1       as        265:        text-decoration: underline;
                    266: }
                    267: div.nav div.top {
                    268:        position: absolute;
                    269:        text-align: center;
                    270:        width: $(($ARG_BIGSIZE - 100))px;
                    271:        margin: 0 50px;
                    272: }
                    273: .left {
                    274:        float: left;
                    275: }
                    276: .right {
                    277:        float: right;
                    278: }
                    279: .clear {
                    280:        clear: both;
                    281: }
                    282:                -->
                    283:                </style>
                    284:        </head>
                    285: <body>
                    286: HTML
                    287: }
                    288: 
                    289: #
                    290: # html_footer()
                    291: #
                    292: html_footer()
                    293: {
                    294:        cat <<HTML
                    295: </body></html>
                    296: HTML
                    297: }
                    298: 
                    299: #
                    300: # html_tn()
                    301: #
                    302: html_tn()
                    303: {
                    304:        tn=$1
                    305:        link=$2
                    306:        title="$3"
                    307: 
                    308:        info=$($BIN_IMGINFO -f $tn)
                    309:        width=$(echo $info | awk '{print $3}')
                    310:        height=$(echo $info | awk '{print $4}')
                    311:        top=$(($(($ARG_TNSIZE - $height)) / 2))
                    312: 
                    313:        test "$title" != "" && title="<div class='t'>$title</div>"
                    314: 
                    315:        cat <<HTML
                    316: <div class="tn">
                    317:        $title
                    318:        <a href="$link" style="top:${top}px">
                    319:                <img alt="$tn" width="$width" height="$height" src="$tn" />
                    320:        </a>
                    321: </div>
                    322: HTML
                    323: }
                    324: 
                    325: #
                    326: # html_img()
                    327: #
                    328: html_img()
                    329: {
                    330:        orig=$1
                    331:        num=$2
                    332:        all=$3
                    333:        img=$4
                    334:        link=$5
                    335:        linkb=$6
                    336:        linkn=$7
                    337: 
                    338:        info=$($BIN_IMGINFO -f $img)
                    339:        width=$(echo $info | awk '{print $3}')
                    340:        height=$(echo $info | awk '{print $4}')
                    341: 
                    342:        desc=$(get_exif_desc $orig)
                    343:        if [ "$desc" != "" ]
                    344:        then
                    345:                desc="<div class='d'>$desc</div>"
                    346:        fi
                    347: 
                    348:        if [ "$linkb" != "" ]
                    349:        then
                    350:                hlinkb="<a href='$linkb'>prev</a>"
                    351:                olinkb="<a class='left' style='height:${height}px' href='$linkb'></a>"
                    352:        fi
                    353: 
                    354:        if [ "$linkn" != "" ]
                    355:        then
                    356:                hlinkn="<a href="$linkn">next</a>"
                    357:                olinkn="<a class='right' style='height:${height}px' href='$linkn'></a>"
                    358:        fi
                    359: 
                    360:        cat <<HTML
                    361: <div class="box">
                    362:        <div class="nav">
                    363:                <div class="top">
                    364:                        <a href="$link">index</a>&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;<a href="$orig">original</a>&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;$num/$all
                    365:                </div>
                    366:                <div class="left">$hlinkb</div>
                    367:                <div class="right">$hlinkn</div>
                    368:        </div>
                    369:        <div class="big">
                    370:                <img alt="$img" width="$width" height="$height" src="$img" />
                    371:        </div>
                    372:        $desc
                    373:        <div class="i">
                    374:                <div class="left">$(get_exif_info $orig)</div>
                    375:                <div class="right">$ARG_TITLE $ARG_COPYRIGHT</div>
                    376:        </div>
                    377:        <div class="over" style='height:${height}px'>
                    378:                $olinkb
                    379:                $olinkn
                    380:        </div>
                    381: </div>
                    382: HTML
                    383: }
                    384: 
                    385: #
1.2       as        386: # html_title()
                    387: #
                    388: html_title()
                    389: {
                    390:        left="$1"
1.3       as        391:        center="$2"
                    392:        right="$3"
1.2       as        393:        cat <<HTML
                    394: <div class="t">
                    395:        <div class="left">$left</div>
                    396:        <div class="right">$right</div>
1.3       as        397:        <div class="center">$center</div>
1.2       as        398:        <div class="clear"></div>
                    399: </div>
                    400: HTML
                    401: }
                    402: 
                    403: #
1.1       as        404: # err
                    405: #
                    406: err()
                    407: {
                    408:        echo "$1" >&2
                    409:        exit 1
                    410: }
                    411: 
                    412: #
                    413: # mysendmail()
                    414: #
                    415: mysendmail()
                    416: {
                    417:        subject=$1
                    418:        (
                    419:                cat <<MAIL
                    420: From: $ARG_MAILFROM
                    421: To: $ARG_MAILTO
                    422: Subject: $subject
                    423: Content-Type: text/plain; charset=iso-8859-1
                    424: X-Mailer: $VERSION
                    425: 
                    426: $(cat)
                    427: MAIL
                    428:        ) | $BIN_SENDMAIL -t
                    429: }
                    430: 
                    431: #
                    432: # get_exif_desc()
                    433: #
                    434: get_exif_desc()
                    435: {
                    436:        img=$1
                    437:        $BIN_EXIF --ifd=0 --tag=0x010e -m $img 2> /dev/null | while read line
                    438:        do
                    439:                echo "$line<br />"
                    440:        done
                    441: }
                    442: 
                    443: #
                    444: # get_exif_ts()
                    445: #
                    446: get_exif_ts()
                    447: {
                    448:        img=$1
                    449:        date=$($BIN_EXIF --ifd=EXIF --tag=0x9003 -m $img 2> /dev/null)
                    450:        if [ "$date" = "" ]
                    451:        then
                    452:                echo "-1"
                    453:                return 1
                    454:        fi
                    455:        date -j -f "%Y:%m:%d %T" "$date" "+%s"
                    456: }
                    457: 
                    458: #
                    459: # get_exif_date()
                    460: #
                    461: get_exif_date()
                    462: {
                    463:        img=$1
                    464:        ts=$(get_exif_ts $img) && date -r $ts "+%d.%m.%Y %H:%M" || echo ""
                    465: }
                    466: 
                    467: #
                    468: # get_exif_value()
                    469: #
                    470: get_exif_value()
                    471: {
                    472:        img=$1
                    473:        hex=$2
                    474:        $BIN_EXIFTRAN -d $img | grep $hex | sed -E 's/^.{45}//'
                    475: }
                    476: 
                    477: #
                    478: # get_exif_info()
                    479: #
                    480: get_exif_info()
                    481: {
                    482:        img=$1
                    483: 
                    484:        exifinfo=
                    485:        created=$(get_exif_date $img) && exifinfo="$created / "
                    486: 
                    487:        for exif in $ARG_EXIF
                    488:        do
                    489:                if echo $exif | grep -q -E '0x[[:alnum:]]{4}'
                    490:                then
                    491:                        exifinfo="$exifinfo$(get_exif_value $img $exif) "
                    492:                else
                    493:                        exifinfo="$exifinfo$exif "
                    494:                fi
                    495:        done
1.4       as        496:        echo $exifinfo | sed -E -e 's/ mm /mm /' -e 's/( |([[:digit:]]))se(c|k)\./\2s/' -e 's/ ISO / ISO/' -e 's/ ISO(\/| )/ \1/'
1.1       as        497: }
                    498: 
                    499: #
                    500: # is_in_list()
                    501: #
                    502: is_in_list()
                    503: {
                    504:        list=$1
                    505:        value=$2
                    506:        for entry in $list
                    507:        do
                    508:                test "$entry" = "$value" && return 0
                    509:        done
                    510:        return 1
                    511: }