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