Annotation of scripts/pgallery/src/pgallery.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/pgallery.sh,v 1.2 2012/08/28 08:15:13 as Exp $
1.1 as 9: #
10:
11: ARG_TITLE="PGallery"
12: ARG_FILES=
13: ARG_FILETYPES="jpg jpeg png gif tif tiff"
14: ARG_TNSIZE="180"
15: ARG_TNQALITY="70"
16: ARG_BIGSIZE="950"
17: ARG_BIGQALITY="90"
18: ARG_INDEX="index.html"
19: ARG_DIR="."
20: ARG_UPDATE=1
21: ARG_COPYRIGHT="© $(date +%Y)"
22:
23: BIN_CONVERT="/usr/local/bin/convert"
24: BIN_EXIFAUTOTRAN="/usr/local/bin/exifautotran"
25: BIN_IMGINFO="/usr/local/bin/imginfo"
26:
27: MKAKEFILE=".htmakefile"
28: VERSION="pgallery-1"
29:
30: #
31: # usage()
32: #
33: usage()
34: {
35: cat <<USAGE
36: usage $0: ( [-f <files>] | [-s <suffix>] ) [-d <dir>] [-n <name>]
37: [-t <thumbnail_size>] [-u <thumbnail_quality>]
38: [-b <big_size>] [-c <big_quality>]
39: [-i <index>] [-U] | -h
40: Options:
41: -b size size from big images in pixel (default: $ARG_BIGSIZE)
42: -c quality quality from big images 0-100% (default: $ARG_BIGQALITY)
43: -d dir gallery dir (default: $ARG_DIR)
44: -f files gallery images
45: -h this page
46: -i name index file name (default: $ARG_INDEX)
47: -n name page title (default: $ARG_TITLE)
48: -s suffix list of suffix. if no \`\`-f'' defined, used to find images
49: in \`\`-d'' directoy. case insensitive
50: (default: $ARG_FILETYPES)
51: -t size size from thumbnail images in pixel (default: $ARG_TNSIZE)
52: -u quality quality from thumbnail images 0-100% (default: $ARG_BIGQALITY)
53: -U no update, new calculation of all images.
54: normally only new and modified images will calculated
55: -C copyright copyright (html) string (default: $ARG_COPYRIGHT)
56: -v print version
57: USAGE
58: exit
59: }
60:
61: #
62: # get_my_path()
63: #
64: get_my_path()
65: {
66: current=$(pwd)
67: cd $(dirname $0)
68: echo $(pwd)/$(basename $0)
69: cd "$current"
70: }
71:
72: #
73: # html_header()
74: #
75: html_header()
76: {
77: cat <<HTML
78: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
79: "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
80: <html xmlns="http://www.w3.org/1999/xhtml">
81: <head>
82: <title>$ARG_TITLE</title>
83: <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
84: <style type="text/css">
85: <!--
86: body {
87: background-color: #464646;
88: background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAFgAAABYB\
89: AMAAACDuy0HAAAAG1BMVEX+/v4BAQH///8KCgoDAwN/f3/19fWAgID8/PzhDwT2AAAACXRSTlMFBQUFBQU\
90: FBQWHDtP9AAALwklEQVR4Xg3KOWOyWhAA0Bn2ci57eXEvQY1JCZp8sQTjVoJLTAkaE0swbj/7ve4UB37FL\
91: W4q86Lwwlh86J/ASAkpWaj+Krbb31HzH0Kjc2tIl7SADaWbpZBPE5dds6jJNyNdjAyKWqdroIixWRQIY6E\
92: /kOY7hIciL/ZfrAO3XP/06AuUJ3mSd/z95OB9vIal0DPlaZWHP7RE6DIXjmKqKkuGr+xNZylOnj1GSlUKv\
93: nxZDBOIzTfMe0fJgJ7c/GIIOdUuKxYyBFUOzvY6AC5AXx8R+o5O4S0j0wqBND3ErIYm/XHFbQjtH1MXD5d\
94: Ubp19OFdjkDlys+HSwrBgHRvL9wVN/pi8ViOIwcv/D1GRW6UuDvJLLQA5lCI17iUdsKYpOuYfMATGnpn/Z\
95: s3W6gov51G+/Vs9Ay//we5kh8uwvEPum6o5HkDMDb3ZWunwtq+UzENU8NphDdbvNtKM3knx5gi6UM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uCcOhZqfekuQxjQ7EoyGUJAwCv/q1JOuJeCc/3lknb76zAquO/DAQhK/6\
134: 2cP8X2s3+IBLIhvL8RHopoHpIArJysYTTmMMeubPXh8W760AvMVH67jqgg06+/ne5MZ631z6yROhloh3dP\
135: QirZoEpr80wgt/cEbhbAQTmRLtGh8lxCwDBBb5OeJ4aEq25XBNMT2rzWedW2zIzj+CCDKlnlyJBzT81qBW\
136: p69h7vlb3TmEV+DNm2rqj1iT7BQuwVVsuPkwq1e5P8tgNjVbIlMzwXeM11kZqjx3KKFOJzc3CAyFVhi8fx\
137: VZ5FvhdAM5mM6kS6OgKu16MFglq3/b/QVIwdw7HUCyeW04JPjC5dO+GC9OfqfB4VX+wwuift+ths2Ss3i6\
138: nkOE+JFyD+wKFL+WMX6nwwDva0S1/O8Mlnida69Ph96fuFvCoRMvXnCfsLPPmC/hA5RnMNE4fDK0pVOQ4B\
139: HLaErzv/wD99ABmjNZk0AAAAABJRU5ErkJggg==");
140: margin: 10px auto;
141: font-family: Geneva,Arial,sans-serif;
142: font-size: 12px;
1.2 as 143: text-shadow: 1px 1px 1px #000;
1.1 as 144: }
145: div.tn {
146: float: left;
147: width: ${ARG_TNSIZE}px;
148: height: ${ARG_TNSIZE}px;
149: vertical-align:text-top;
150: text-align: center;
151: margin: 4px;
152: }
153: div.tn a {
154: position: relative;
155: display: inline-block;
156: height: ${ARG_TNSIZE}px;
157: }
158: div.tn, div.big {
159: background-color: black;
160: border-width: 1px;
161: border-style: solid;
162: border-color: gray;
163: box-shadow: 1px 1px 2px #000;
164: padding: 1px;
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;
1.2 as 181: /* shell fuck of: missing CTLARI (shouldn't happen) - WTF?! */
182: width: $(($ARG_BIGSIZE / 2))px;
1.1 as 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.c {
228: width: ${ARG_BIGSIZE}px;
229: text-align: right;
230: font-size: 90%;
231: color: #808080;
232: height: 25px;
233: line-height: 25px;
234: position: relative;
235: left: 4px;
236: }
237: body > div.c {
238: text-align: center;
239: font-size: 90%;
240: color: #808080;
241: height: 25px;
242: line-height: 25px;
243: position: relative;
244: margin: 4px;
245: }
246: a img {
247: border-width: 0;
248: }
249: a {
250: }
251: div.nav {
252: width: ${ARG_BIGSIZE}px;
253: height: 20px;
254: }
255: div.nav a {
256: color: #FFF;
257: text-decoration: none;
258: }
259: div.nav a:hover {
260: text-decoration: underline;
261: }
262: div.nav div.top {
263: position: absolute;
264: text-align: center;
1.2 as 265: width: $(($ARG_BIGSIZE - 100))px;
266: margin: 0 50px;
1.1 as 267: }
268: .left {
269: float: left;
270: }
271: .right {
272: float: right;
273: }
274: .clear {
275: clear: both;
276: }
277: -->
278: </style>
279: </head>
280: <body>
281: HTML
282: }
283:
284: #
285: # html_footer()
286: #
287: html_footer()
288: {
289: cat <<HTML
290: </body></html>
291: HTML
292: }
293:
294: #
295: # html_tn()
296: #
297: html_tn()
298: {
299: tn=$1
300: link=$2
301:
302: info=$($BIN_IMGINFO -f $tn)
303: width=$(echo $info | awk '{print $3}')
304: height=$(echo $info | awk '{print $4}')
305: top=$(($(($ARG_TNSIZE - $height)) / 2))
306:
307: cat <<HTML
308: <div class="tn">
309: <a href="$link" style="top:${top}px">
310: <img alt="$tn" width="$width" height="$height" src="$tn" />
311: </a>
312: </div>
313: HTML
314: }
315:
316: #
317: # html_img()
318: #
319: html_img()
320: {
321: img=$1
322: link=$2
323: linkb=$3
324: linkn=$4
325:
1.3 ! as 326: info=$($BIN_IMGINFO -f $img)
! 327: width=$(echo $info | awk '{print $3}')
! 328: height=$(echo $info | awk '{print $4}')
1.1 as 329:
330: if [ "$linkb" != "" ]
331: then
332: hlinkb="<a href='$linkb'>zurück</a>"
333: olinkb="<a class='left' style='height:${height}px' href='$linkb'></a>"
334: fi
335:
336: if [ "$linkn" != "" ]
337: then
338: hlinkn="<a href="$linkn">weiter</a>"
339: olinkn="<a class='right' style='height:${height}px' href='$linkn'></a>"
340: fi
341:
342: cat <<HTML
343: <div class="box">
344: <div class="nav">
1.2 as 345: <div class="top"><a href="$link">Index</a></div>
1.1 as 346: <div class="left">$hlinkb</div>
347: <div class="right">$hlinkn</div>
348: </div>
349: <div class="big">
1.3 ! as 350: <img alt="$img" width="$width" height="$height" src="$img" />
1.1 as 351: </div>
352: <div class="c">
353: $ARG_TITLE $ARG_COPYRIGHT
354: </div>
355: <div class="over" style='height:${height}px'>
356: $olinkb
357: $olinkn
358: </div>
359: </div>
360: HTML
361: }
362:
363: #
364: # err
365: #
366: err()
367: {
368: echo "$1" >&2
369: exit 1
370: }
371:
372:
373: # parse args
374: while [ "$1" != "" ]
375: do
376: arg=$1
377: shift
378: case $arg in
379: -h)
380: usage
381: ;;
382: -n)
383: ARG_TITLE=$1
384: shift
385: ;;
386: -t)
387: ARG_TNSIZE=$1
388: shift
389: ;;
390: -u)
391: ARG_TNQALITY=$1
392: shift
393: ;;
394: -b)
395: ARG_BIGSIZE=$1
396: shift
397: ;;
398: -c)
399: ARG_BIGQALITY=$1
400: shift
401: ;;
402: -f)
403: ARG_FILES=$1
404: shift
405: ;;
406: -s)
407: ARG_FILETYPES=$1
408: shift
409: ;;
410: -d)
411: ARG_DIR=$1
412: shift
413: ;;
414: -C)
415: ARG_COPYRIGHT=$1
416: shift
417: ;;
418: -U)
419: ARG_UPDATE=0
420: ;;
421: -v)
422: echo $VERSION
423: exit
424: ;;
425: *)
426: echo "unknown argument $arg"
427: exit
428: esac
429: done
430:
431: MY=$(get_my_path)
432: cd "$ARG_DIR" || exit 1
433:
434: # if no images defined, find files
435: if [ "$ARG_FILES" = "" -a "$ARG_FILETYPES" != "" ]
436: then
437: match=
438: for type in $ARG_FILETYPES
439: do
440: match="$match *.$(echo $type | tr '[:lower:]' '[:upper:]')"
441: match="$match *.$(echo $type | tr '[:upper:]' '[:lower:]')"
442: done
443: ARG_FILES=$(cd $ARG_DIR && ls $match 2>/dev/null)
444: fi
445:
446: # Filter big and thumbnails
447: echo -n "find images"
448: FLIST=
449: for file in $ARG_FILES
450: do
451: test $(echo $file | grep -E '\.(tn|big)\.jpg$') && continue
452: FLIST="$FLIST $file"
453: echo -n " $file"
454: done
455: echo
456:
457: test $(echo $FLIST | wc -w) -eq 0 && err "error: no image found in \`\`$ARG_DIR''"
458:
459: # Create make file to rotate und convert all big and thumbnails.
460: # Is needed to define the new real image sizes.
461: echo "all: tns" > $MKAKEFILE
462: targets=""
463: for file in $FLIST
464: do
465: tn="${file}.tn.jpg"
466: big="${file}.big.jpg"
467: targets="$targets $tn"
468:
469: target=
470: if [ $ARG_UPDATE -eq 1 ]
471: then
472: target="$tn: $ME $file"
473: else
474: target="$tn::"
475: fi
476:
477: (
478: cat <<MAKE
479: $target
480: $BIN_EXIFAUTOTRAN $file
481: $BIN_CONVERT -verbose -thumbnail ${ARG_TNSIZE}x${ARG_TNSIZE} -quality $ARG_TNQALITY $file $tn
482: $BIN_CONVERT -verbose -thumbnail ${ARG_BIGSIZE}x${ARG_BIGSIZE} -quality $ARG_BIGQALITY $file $big
483: MAKE
484: ) >> $MKAKEFILE
485: done
486: echo "tns: $targets" >> $MKAKEFILE
487:
488: make -f $MKAKEFILE
489: rm $MKAKEFILE
490:
491: # create single html files
492: index=""
493: i=0
494: echo -n "create single html files "
495: for file in $FLIST
496: do
497: h=$i
498: i=$(($i + 1))
499: j=$(($i + 1))
500:
501: tn="${file}.tn.jpg"
502: big="${file}.big.jpg"
503: imglink="${file}.html"
504:
505: if [ $i -ne 1 ]
506: then
507: linkb=$(echo $FLIST | awk "{print \$$h}").html
508: fi
509: linkn=$(echo $FLIST | awk "{print \$$j}")
510: test "$linkn" != "" && linkn="$linkn.html"
511:
512: echo -n .
513: index="$index $(html_tn $tn $imglink)"
514: (
515: html_header
516: html_img $big $ARG_INDEX "$linkb" "$linkn"
517: html_footer
518: ) > $imglink
519: done
520: echo
521:
522: # create html index
523: echo create html index
524: (
525: html_header
526: echo $index
527: echo "<div class='clear'></div>"
528: echo "<div class='c'>$ARG_TITLE $ARG_COPYRIGHT</div>"
529: html_footer
530: ) > $ARG_INDEX