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