Annotation of scripts/pgallery/src/libpgallery.sh, revision 1.2
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.2 ! as 8: # $Paefchen: scripts/pgallery/src/libpgallery.sh,v 1.1 2012/08/31 12:33:07 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-size: 120%;
! 136: font-weight: bold;
! 137: position: relative;
! 138: bottom: 10px;
! 139: padding: 6px;
! 140: border-width: 0 0 1px 0;
! 141: border-color: gray;
! 142: border-style: solid;
! 143: }
1.1 as 144: div.tn a {
145: position: relative;
146: display: inline-block;
147: height: ${ARG_TNSIZE}px;
148: }
149: div.tn, div.big {
150: background-color: black;
151: border-width: 1px;
152: border-style: solid;
153: border-color: gray;
154: box-shadow: 1px 1px 2px #000;
155: padding: 1px;
156: border-radius: 3px;
157: }
158: div.tn:hover {
159: background-color: #222;
160: }
161: div.big {
162: display: inline-block;
163: width: ${ARG_BIGSIZE}px;
164: }
165: div.over {
166: width: ${ARG_BIGSIZE}px;
167: position: absolute;
168: top: 30px;
169: padding: 1px;
170: }
171: div.over a.left, div.over a.right {
172: display: block;
173: /* shell fuck of: missing CTLARI (shouldn't happen) - WTF?! */
174: width: $(($ARG_BIGSIZE / 2))px;
175: position: relative;
176: top: 1px;
177: left: 1px;
178: background-repeat: no-repeat;
179: }
180: div.over a.left:hover {
181: background-position: 5% center;
182: background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAB0AAAAwC\
183: AYAAADtoXHnAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAh9JREFUeNrE2L1Lw0A\
184: UAHATSivSZii0ldpBnMU6SgYJpQUJDlk7dLV+LTqIiIv4B7kLolBKQRA6GLqUDMEhqKAlhUIR4125SHo0b\
185: XJ51x68pDSX+3G5I/dyguM4S/MuMfeHIAiQ7Yo+//+OocAYPm+jWEXxg8JC8erCgvt4AXrqgkkUJRRZ6jq\
186: G71EMRcAeil6wWq2uGYZx1ul0jjRNy5Jey6PauKcRJ5NIhklCoaE4QODNYDCwHVJ6vd5HIpE4xNdQxKOiM\
187: 0G3FIvFc4Imo6CBQV3XXwioje5jREOBkiQdE3SLFWUFFXJfaJQVLP2DIWdvFDA+9pYKiMKBAVFYMAAKD85\
188: A+YBTUH6gD8oXnIDyB31QviCFzgekUPxYVe4ghW7ixhRFueQKUmgZN9hut1s0aNv2V6FQOAUBqRvT+IAaX\
189: 6crWZb1hsqQJFfPkPnpJz6YpmnQlXK5XD6TycRIcrUDib7jQ71ev+v3+9/eSqlUKt1qtU4IvIFid2x9jDC\
190: muJE9PG6qql7jcaTHttvt6gh2J1MZYva6ees+d9jnjcQXnoDyh31WGb7wlPWUHzwjc+ADB8iR4OGA2SAsH\
191: CLvhYNDZvgwMMO3THSY8auNBS6xfrVFhZUoaGjYk+qA7DkEgmu12i1Bs1C7K1NhvLviecTLEOhEuFKpXDW\
192: bzcdGo/Egy/KFZzKJPHbMVsiEyVPXTRRPeMdMWMQuqLi0gPInwACOBcZx3lRFMwAAAABJRU5ErkJggg==");
193: }
194: div.over a.right:hover {
195: background-position: 95% center;
196: background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAB0AAAAwC\
197: AYAAADtoXHnAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAiJJREFUeNrE2D1Lw0A\
198: YAOAmlNbBdii0FVM6OEu7SgcJpRUJDlk7dE21uuggIi7iD/IX+AGlFAXBDqVLyVCCBBW0JFhwMN7JHRxnY\
199: 5PcnX3hhSM58nB3+Xhzkud5sf8OiWjLPn2+eGF4gHEChLkOcgUdt0E+isAlhCVAbiGQjGeQ1yBdHjAeKZ7\
200: SCgR1Xc8Nh8M90zQPG42GAo7lQFZBLhOzwSXgKI1kMrk7mUxePBTT6dQB8Dk8B1IHmUbTLrOMFI8WjsIol\
201: 8tHHhW8YRKV0QWNwWDwIBKm0RK8aDqdbouEaRReQBUNkygJV0XCNBojnldh8CxUOOyHCoX/QoXB81AhcBC\
202: UOxwU5QqHQbnBYVFWODLKDEdFo8IanGYWNBSsquoJgkus6C+4UCgcOI7zRsP9fv8OoTWM8qh57mHlaFnWp\
203: 23bFn1SUZQiambm1bphYgMWddlsNp7P51fpk+Px2ETNV1YUf383Qa5BsNfr7adSqQzZyXXd91ardUmUs8x\
204: rWYNrBcD2aDQa0GsJ11fTtDO0ntssd28UcAfXzSxvpLBg5DcSKyhH/cowgVG+p8xg2MqBCximRuIGBq0Gu\
205: YJB6l7u4LwKXwjo9y8jFPT7a6uKBGehqmiQRhO45BAJ0ijcQTGazeaFSJBGl/DUkrsrvMFZa/pzE1UqleN\
206: Op3PV7XZv6vX6KU+QRMkdM3gzFal+TyBvQX7w3DGTFrELKscWEN8CDADBm8pgcciwqgAAAABJRU5ErkJgg\
207: g==");
208: }
209: div.big a {
210: position: relative;
211: display: inline-block;
212: width: ${ARG_BIGSIZE}px;
213: }
214: div.box {
215: text-align: center;
216: width: ${ARG_BIGSIZE}px;
217: margin: auto;
218: }
219: div.box div.d {
220: width: ${ARG_BIGSIZE}px;
221: padding: 5px;
222: text-align: center;
223: }
224: div.box div.i {
225: width: ${ARG_BIGSIZE}px;
226: font-size: 90%;
227: height: 25px;
228: line-height: 25px;
229: position: relative;
230: }
231: body > div.c {
232: text-align: center;
233: font-size: 90%;
234: height: 25px;
235: line-height: 25px;
236: position: relative;
237: margin: 4px;
238: }
239: a img {
240: border-width: 0;
241: }
242: a {
243: }
244: div.nav {
245: width: ${ARG_BIGSIZE}px;
246: height: 20px;
247: }
248: div.nav a {
249: color: #FFF;
250: text-decoration: none;
251: }
252: div.nav a:hover {
253: text-decoration: underline;
254: }
255: div.nav div.top {
256: position: absolute;
257: text-align: center;
258: width: $(($ARG_BIGSIZE - 100))px;
259: margin: 0 50px;
260: }
261: .left {
262: float: left;
263: }
264: .right {
265: float: right;
266: }
267: .clear {
268: clear: both;
269: }
270: -->
271: </style>
272: </head>
273: <body>
274: HTML
275: }
276:
277: #
278: # html_footer()
279: #
280: html_footer()
281: {
282: cat <<HTML
283: </body></html>
284: HTML
285: }
286:
287: #
288: # html_tn()
289: #
290: html_tn()
291: {
292: tn=$1
293: link=$2
294: title="$3"
295:
296: info=$($BIN_IMGINFO -f $tn)
297: width=$(echo $info | awk '{print $3}')
298: height=$(echo $info | awk '{print $4}')
299: top=$(($(($ARG_TNSIZE - $height)) / 2))
300:
301: test "$title" != "" && title="<div class='t'>$title</div>"
302:
303: cat <<HTML
304: <div class="tn">
305: $title
306: <a href="$link" style="top:${top}px">
307: <img alt="$tn" width="$width" height="$height" src="$tn" />
308: </a>
309: </div>
310: HTML
311: }
312:
313: #
314: # html_img()
315: #
316: html_img()
317: {
318: orig=$1
319: num=$2
320: all=$3
321: img=$4
322: link=$5
323: linkb=$6
324: linkn=$7
325:
326: info=$($BIN_IMGINFO -f $img)
327: width=$(echo $info | awk '{print $3}')
328: height=$(echo $info | awk '{print $4}')
329:
330: desc=$(get_exif_desc $orig)
331: if [ "$desc" != "" ]
332: then
333: desc="<div class='d'>$desc</div>"
334: fi
335:
336: if [ "$linkb" != "" ]
337: then
338: hlinkb="<a href='$linkb'>prev</a>"
339: olinkb="<a class='left' style='height:${height}px' href='$linkb'></a>"
340: fi
341:
342: if [ "$linkn" != "" ]
343: then
344: hlinkn="<a href="$linkn">next</a>"
345: olinkn="<a class='right' style='height:${height}px' href='$linkn'></a>"
346: fi
347:
348: cat <<HTML
349: <div class="box">
350: <div class="nav">
351: <div class="top">
352: <a href="$link">index</a> | <a href="$orig">original</a> | $num/$all
353: </div>
354: <div class="left">$hlinkb</div>
355: <div class="right">$hlinkn</div>
356: </div>
357: <div class="big">
358: <img alt="$img" width="$width" height="$height" src="$img" />
359: </div>
360: $desc
361: <div class="i">
362: <div class="left">$(get_exif_info $orig)</div>
363: <div class="right">$ARG_TITLE $ARG_COPYRIGHT</div>
364: </div>
365: <div class="over" style='height:${height}px'>
366: $olinkb
367: $olinkn
368: </div>
369: </div>
370: HTML
371: }
372:
373: #
1.2 ! as 374: # html_title()
! 375: #
! 376: html_title()
! 377: {
! 378: left="$1"
! 379: right="$2"
! 380: cat <<HTML
! 381: <div class="t">
! 382: <div class="left">$left</div>
! 383: <div class="right">$right</div>
! 384: <div class="clear"></div>
! 385: </div>
! 386: HTML
! 387: }
! 388:
! 389: #
1.1 as 390: # err
391: #
392: err()
393: {
394: echo "$1" >&2
395: exit 1
396: }
397:
398: #
399: # mysendmail()
400: #
401: mysendmail()
402: {
403: subject=$1
404: (
405: cat <<MAIL
406: From: $ARG_MAILFROM
407: To: $ARG_MAILTO
408: Subject: $subject
409: Content-Type: text/plain; charset=iso-8859-1
410: X-Mailer: $VERSION
411:
412: $(cat)
413: MAIL
414: ) | $BIN_SENDMAIL -t
415: }
416:
417: #
418: # get_exif_desc()
419: #
420: get_exif_desc()
421: {
422: img=$1
423: $BIN_EXIF --ifd=0 --tag=0x010e -m $img 2> /dev/null | while read line
424: do
425: echo "$line<br />"
426: done
427: }
428:
429: #
430: # get_exif_ts()
431: #
432: get_exif_ts()
433: {
434: img=$1
435: date=$($BIN_EXIF --ifd=EXIF --tag=0x9003 -m $img 2> /dev/null)
436: if [ "$date" = "" ]
437: then
438: echo "-1"
439: return 1
440: fi
441: date -j -f "%Y:%m:%d %T" "$date" "+%s"
442: }
443:
444: #
445: # get_exif_date()
446: #
447: get_exif_date()
448: {
449: img=$1
450: ts=$(get_exif_ts $img) && date -r $ts "+%d.%m.%Y %H:%M" || echo ""
451: }
452:
453: #
454: # get_exif_value()
455: #
456: get_exif_value()
457: {
458: img=$1
459: hex=$2
460: $BIN_EXIFTRAN -d $img | grep $hex | sed -E 's/^.{45}//'
461: }
462:
463: #
464: # get_exif_info()
465: #
466: get_exif_info()
467: {
468: img=$1
469:
470: exifinfo=
471: created=$(get_exif_date $img) && exifinfo="$created / "
472:
473: for exif in $ARG_EXIF
474: do
475: if echo $exif | grep -q -E '0x[[:alnum:]]{4}'
476: then
477: exifinfo="$exifinfo$(get_exif_value $img $exif) "
478: else
479: exifinfo="$exifinfo$exif "
480: fi
481: done
482: echo $exifinfo | sed -E -e 's/ mm /mm /' -e 's/ se(c|k)./s/' -e 's/ ISO / ISO/' -e 's/ ISO(\/| )/ \1/'
483: }
484:
485: #
486: # is_in_list()
487: #
488: is_in_list()
489: {
490: list=$1
491: value=$2
492: for entry in $list
493: do
494: test "$entry" = "$value" && return 0
495: done
496: return 1
497: }