Annotation of scripts/pgallery/src/pgallery.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/pgallery.sh,v 1.4 2012/08/28 08:43:05 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)"
1.5 ! as 22: ARG_INFOFILE="pgallery.txt"
1.1 as 23:
24: BIN_CONVERT="/usr/local/bin/convert"
25: BIN_EXIFAUTOTRAN="/usr/local/bin/exifautotran"
26: BIN_IMGINFO="/usr/local/bin/imginfo"
27:
28: MKAKEFILE=".htmakefile"
1.5 ! as 29: VERSION="pgallery-1.1"
1.1 as 30:
31: #
32: # usage()
33: #
34: usage()
35: {
36: cat <<USAGE
37: usage $0: ( [-f <files>] | [-s <suffix>] ) [-d <dir>] [-n <name>]
38: [-t <thumbnail_size>] [-u <thumbnail_quality>]
39: [-b <big_size>] [-c <big_quality>]
1.4 as 40: [-i <index>] [-C <copyright>] [-U] | -h | -v
1.1 as 41: Options:
42: -b size size from big images in pixel (default: $ARG_BIGSIZE)
43: -c quality quality from big images 0-100% (default: $ARG_BIGQALITY)
44: -d dir gallery dir (default: $ARG_DIR)
45: -f files gallery images
46: -h this page
47: -i name index file name (default: $ARG_INDEX)
48: -n name page title (default: $ARG_TITLE)
49: -s suffix list of suffix. if no \`\`-f'' defined, used to find images
50: in \`\`-d'' directoy. case insensitive
51: (default: $ARG_FILETYPES)
52: -t size size from thumbnail images in pixel (default: $ARG_TNSIZE)
53: -u quality quality from thumbnail images 0-100% (default: $ARG_BIGQALITY)
1.4 as 54: -v print version
55: -C copyright copyright (html) string (default: $ARG_COPYRIGHT)
1.5 ! as 56: -I file info text file for pgallery. info file paras prefered.
! 57: the syntax of the file is MAKE(1)
! 58: supported variable: TITLE COPYRIGHT INDEX FILETYPES TNSIZE
! 59: TNQALITY BIGSIZE BIGQALITY
1.1 as 60: -U no update, new calculation of all images.
61: normally only new and modified images will calculated
62: USAGE
63: exit
64: }
65:
66: #
67: # get_my_path()
68: #
69: get_my_path()
70: {
71: current=$(pwd)
72: cd $(dirname $0)
73: echo $(pwd)/$(basename $0)
74: cd "$current"
75: }
76:
77: #
78: # html_header()
79: #
80: html_header()
81: {
82: cat <<HTML
83: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
84: "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
85: <html xmlns="http://www.w3.org/1999/xhtml">
86: <head>
87: <title>$ARG_TITLE</title>
88: <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
89: <style type="text/css">
90: <!--
91: body {
92: background-color: #464646;
93: background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAFgAAABYB\
94: AMAAACDuy0HAAAAG1BMVEX+/v4BAQH///8KCgoDAwN/f3/19fWAgID8/PzhDwT2AAAACXRSTlMFBQUFBQU\
95: FBQWHDtP9AAALwklEQVR4Xg3KOWOyWhAA0Bn2ci57eXEvQY1JCZp8sQTjVoJLTAkaE0swbj/7ve4UB37FL\
96: W4q86Lwwlh86J/ASAkpWaj+Krbb31HzH0Kjc2tIl7SADaWbpZBPE5dds6jJNyNdjAyKWqdroIixWRQIY6E\
97: /kOY7hIciL/ZfrAO3XP/06AuUJ3mSd/z95OB9vIal0DPlaZWHP7RE6DIXjmKqKkuGr+xNZylOnj1GSlUKv\
98: nxZDBOIzTfMe0fJgJ7c/GIIOdUuKxYyBFUOzvY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cD/PX6LaGd25CuN\
136: HG/vgeIB1kcpCme+J8idlcjfBALAJSggznsGHGOAJgdGduMnZg+bAaeGASGV9bh/X2wPsVTmBLxmTTQsBG\
137: FkEOkZJTsGAm+HrtMDbWwvTXOutX1u7BxIq9Xib6DkFMbUitNdrYsULkahsAhBEh9FjdzL9BNARxTSr7T3\
138: u1rE+IWUmCIpwTZHZCu5l9THCuCcOhZqfekuQxjQ7EoyGUJAwCv/q1JOuJeCc/3lknb76zAquO/DAQhK/6\
139: 2cP8X2s3+IBLIhvL8RHopoHpIArJysYTTmMMeubPXh8W760AvMVH67jqgg06+/ne5MZ631z6yROhloh3dP\
140: QirZoEpr80wgt/cEbhbAQTmRLtGh8lxCwDBBb5OeJ4aEq25XBNMT2rzWedW2zIzj+CCDKlnlyJBzT81qBW\
141: p69h7vlb3TmEV+DNm2rqj1iT7BQuwVVsuPkwq1e5P8tgNjVbIlMzwXeM11kZqjx3KKFOJzc3CAyFVhi8fx\
142: VZ5FvhdAM5mM6kS6OgKu16MFglq3/b/QVIwdw7HUCyeW04JPjC5dO+GC9OfqfB4VX+wwuift+ths2Ss3i6\
143: nkOE+JFyD+wKFL+WMX6nwwDva0S1/O8Mlnida69Ph96fuFvCoRMvXnCfsLPPmC/hA5RnMNE4fDK0pVOQ4B\
144: HLaErzv/wD99ABmjNZk0AAAAABJRU5ErkJggg==");
145: margin: 10px auto;
146: font-family: Geneva,Arial,sans-serif;
147: font-size: 12px;
1.2 as 148: text-shadow: 1px 1px 1px #000;
1.1 as 149: }
150: div.tn {
151: float: left;
152: width: ${ARG_TNSIZE}px;
153: height: ${ARG_TNSIZE}px;
154: vertical-align:text-top;
155: text-align: center;
156: margin: 4px;
157: }
158: div.tn a {
159: position: relative;
160: display: inline-block;
161: height: ${ARG_TNSIZE}px;
162: }
163: div.tn, div.big {
164: background-color: black;
165: border-width: 1px;
166: border-style: solid;
167: border-color: gray;
168: box-shadow: 1px 1px 2px #000;
169: padding: 1px;
1.4 as 170: border-radius: 3px;
1.1 as 171: }
172: div.tn:hover {
173: background-color: #222;
174: }
175: div.big {
176: display: inline-block;
177: width: ${ARG_BIGSIZE}px;
178: }
179: div.over {
180: width: ${ARG_BIGSIZE}px;
181: position: absolute;
182: top: 30px;
183: padding: 1px;
184: }
185: div.over a.left, div.over a.right {
186: display: block;
1.2 as 187: /* shell fuck of: missing CTLARI (shouldn't happen) - WTF?! */
188: width: $(($ARG_BIGSIZE / 2))px;
1.1 as 189: position: relative;
190: top: 1px;
191: left: 1px;
192: background-repeat: no-repeat;
193: }
194: div.over a.left:hover {
195: background-position: 5% center;
196: background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAB0AAAAwC\
197: AYAAADtoXHnAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAh9JREFUeNrE2L1Lw0A\
198: UAHATSivSZii0ldpBnMU6SgYJpQUJDlk7dLV+LTqIiIv4B7kLolBKQRA6GLqUDMEhqKAlhUIR4125SHo0b\
199: XJ51x68pDSX+3G5I/dyguM4S/MuMfeHIAiQ7Yo+//+OocAYPm+jWEXxg8JC8erCgvt4AXrqgkkUJRRZ6jq\
200: G71EMRcAeil6wWq2uGYZx1ul0jjRNy5Jey6PauKcRJ5NIhklCoaE4QODNYDCwHVJ6vd5HIpE4xNdQxKOiM\
201: 0G3FIvFc4Imo6CBQV3XXwioje5jREOBkiQdE3SLFWUFFXJfaJQVLP2DIWdvFDA+9pYKiMKBAVFYMAAKD85\
202: A+YBTUH6gD8oXnIDyB31QviCFzgekUPxYVe4ghW7ixhRFueQKUmgZN9hut1s0aNv2V6FQOAUBqRvT+IAaX\
203: 6crWZb1hsqQJFfPkPnpJz6YpmnQlXK5XD6TycRIcrUDib7jQ71ev+v3+9/eSqlUKt1qtU4IvIFid2x9jDC\
204: muJE9PG6qql7jcaTHttvt6gh2J1MZYva6ees+d9jnjcQXnoDyh31WGb7wlPWUHzwjc+ADB8iR4OGA2SAsH\
205: CLvhYNDZvgwMMO3THSY8auNBS6xfrVFhZUoaGjYk+qA7DkEgmu12i1Bs1C7K1NhvLviecTLEOhEuFKpXDW\
206: bzcdGo/Egy/KFZzKJPHbMVsiEyVPXTRRPeMdMWMQuqLi0gPInwACOBcZx3lRFMwAAAABJRU5ErkJggg==");
207: }
208: div.over a.right:hover {
209: background-position: 95% center;
210: background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAB0AAAAwC\
211: AYAAADtoXHnAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAiJJREFUeNrE2D1Lw0A\
212: YAOAmlNbBdii0FVM6OEu7SgcJpRUJDlk7dE21uuggIi7iD/IX+AGlFAXBDqVLyVCCBBW0JFhwMN7JHRxnY\
213: 5PcnX3hhSM58nB3+Xhzkud5sf8OiWjLPn2+eGF4gHEChLkOcgUdt0E+isAlhCVAbiGQjGeQ1yBdHjAeKZ7\
214: SCgR1Xc8Nh8M90zQPG42GAo7lQFZBLhOzwSXgKI1kMrk7mUxePBTT6dQB8Dk8B1IHmUbTLrOMFI8WjsIol\
215: 8tHHhW8YRKV0QWNwWDwIBKm0RK8aDqdbouEaRReQBUNkygJV0XCNBojnldh8CxUOOyHCoX/QoXB81AhcBC\
216: UOxwU5QqHQbnBYVFWODLKDEdFo8IanGYWNBSsquoJgkus6C+4UCgcOI7zRsP9fv8OoTWM8qh57mHlaFnWp\
217: 23bFn1SUZQiambm1bphYgMWddlsNp7P51fpk+Px2ETNV1YUf383Qa5BsNfr7adSqQzZyXXd91ardUmUs8x\
218: rWYNrBcD2aDQa0GsJ11fTtDO0ntssd28UcAfXzSxvpLBg5DcSKyhH/cowgVG+p8xg2MqBCximRuIGBq0Gu\
219: YJB6l7u4LwKXwjo9y8jFPT7a6uKBGehqmiQRhO45BAJ0ijcQTGazeaFSJBGl/DUkrsrvMFZa/pzE1UqleN\
220: Op3PV7XZv6vX6KU+QRMkdM3gzFal+TyBvQX7w3DGTFrELKscWEN8CDADBm8pgcciwqgAAAABJRU5ErkJgg\
221: g==");
222: }
223: div.big a {
224: position: relative;
225: display: inline-block;
226: width: ${ARG_BIGSIZE}px;
227: }
228: div.box {
229: text-align: center;
230: width: ${ARG_BIGSIZE}px;
231: margin: auto;
232: }
233: div.box div.c {
234: width: ${ARG_BIGSIZE}px;
235: text-align: right;
236: font-size: 90%;
237: color: #808080;
238: height: 25px;
239: line-height: 25px;
240: position: relative;
241: left: 4px;
242: }
243: body > div.c {
244: text-align: center;
245: font-size: 90%;
246: color: #808080;
247: height: 25px;
248: line-height: 25px;
249: position: relative;
250: margin: 4px;
251: }
252: a img {
253: border-width: 0;
254: }
255: a {
256: }
257: div.nav {
258: width: ${ARG_BIGSIZE}px;
259: height: 20px;
260: }
261: div.nav a {
262: color: #FFF;
263: text-decoration: none;
264: }
265: div.nav a:hover {
266: text-decoration: underline;
267: }
268: div.nav div.top {
269: position: absolute;
270: text-align: center;
1.2 as 271: width: $(($ARG_BIGSIZE - 100))px;
272: margin: 0 50px;
1.1 as 273: }
274: .left {
275: float: left;
276: }
277: .right {
278: float: right;
279: }
280: .clear {
281: clear: both;
282: }
283: -->
284: </style>
285: </head>
286: <body>
287: HTML
288: }
289:
290: #
291: # html_footer()
292: #
293: html_footer()
294: {
295: cat <<HTML
296: </body></html>
297: HTML
298: }
299:
300: #
301: # html_tn()
302: #
303: html_tn()
304: {
305: tn=$1
306: link=$2
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: cat <<HTML
314: <div class="tn">
315: <a href="$link" style="top:${top}px">
316: <img alt="$tn" width="$width" height="$height" src="$tn" />
317: </a>
318: </div>
319: HTML
320: }
321:
322: #
323: # html_img()
324: #
325: html_img()
326: {
327: img=$1
328: link=$2
329: linkb=$3
330: linkn=$4
331:
1.3 as 332: info=$($BIN_IMGINFO -f $img)
333: width=$(echo $info | awk '{print $3}')
334: height=$(echo $info | awk '{print $4}')
1.1 as 335:
336: if [ "$linkb" != "" ]
337: then
338: hlinkb="<a href='$linkb'>zurück</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">weiter</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">
1.2 as 351: <div class="top"><a href="$link">Index</a></div>
1.1 as 352: <div class="left">$hlinkb</div>
353: <div class="right">$hlinkn</div>
354: </div>
355: <div class="big">
1.3 as 356: <img alt="$img" width="$width" height="$height" src="$img" />
1.1 as 357: </div>
358: <div class="c">
359: $ARG_TITLE $ARG_COPYRIGHT
360: </div>
361: <div class="over" style='height:${height}px'>
362: $olinkb
363: $olinkn
364: </div>
365: </div>
366: HTML
367: }
368:
369: #
370: # err
371: #
372: err()
373: {
374: echo "$1" >&2
375: exit 1
376: }
377:
378:
379: # parse args
380: while [ "$1" != "" ]
381: do
382: arg=$1
383: shift
384: case $arg in
385: -h)
386: usage
387: ;;
388: -n)
389: ARG_TITLE=$1
390: shift
391: ;;
392: -t)
393: ARG_TNSIZE=$1
394: shift
395: ;;
396: -u)
397: ARG_TNQALITY=$1
398: shift
399: ;;
400: -b)
401: ARG_BIGSIZE=$1
402: shift
403: ;;
404: -c)
405: ARG_BIGQALITY=$1
406: shift
407: ;;
408: -f)
409: ARG_FILES=$1
410: shift
411: ;;
412: -s)
413: ARG_FILETYPES=$1
414: shift
415: ;;
416: -d)
417: ARG_DIR=$1
418: shift
419: ;;
420: -C)
421: ARG_COPYRIGHT=$1
422: shift
423: ;;
1.5 ! as 424: -I)
! 425: ARG_INFOFILE=$1
! 426: shift
! 427: ;;
1.1 as 428: -U)
429: ARG_UPDATE=0
430: ;;
431: -v)
432: echo $VERSION
433: exit
434: ;;
435: *)
436: echo "unknown argument $arg"
437: exit
438: esac
439: done
440:
1.5 ! as 441: # parese info file
! 442: if [ "$ARG_INFOFILE" != "" ]
! 443: then
! 444: test -f $ARG_INFOFILE || err "info file not found \`\`$ARG_INFOFILE''"
! 445: for n in TITLE COPYRIGHT INDEX FILETYPES TNSIZE TNQALITY BIGSIZE BIGQALITY
! 446: do
! 447: v=$(make -f $ARG_INFOFILE -V$n)
! 448: test "$v" = "" && continue
! 449: eval "ARG_$n='$v'"
! 450: done
! 451: fi
! 452:
! 453: echo $ARG_COPYRIGHT
! 454: exit
! 455:
1.1 as 456: MY=$(get_my_path)
457: cd "$ARG_DIR" || exit 1
458:
459: # if no images defined, find files
460: if [ "$ARG_FILES" = "" -a "$ARG_FILETYPES" != "" ]
461: then
462: match=
463: for type in $ARG_FILETYPES
464: do
465: match="$match *.$(echo $type | tr '[:lower:]' '[:upper:]')"
466: match="$match *.$(echo $type | tr '[:upper:]' '[:lower:]')"
467: done
468: ARG_FILES=$(cd $ARG_DIR && ls $match 2>/dev/null)
469: fi
470:
471: # Filter big and thumbnails
472: echo -n "find images"
473: FLIST=
474: for file in $ARG_FILES
475: do
476: test $(echo $file | grep -E '\.(tn|big)\.jpg$') && continue
477: FLIST="$FLIST $file"
478: echo -n " $file"
479: done
480: echo
481:
482: test $(echo $FLIST | wc -w) -eq 0 && err "error: no image found in \`\`$ARG_DIR''"
483:
1.5 ! as 484: # find new and to update images
! 485: FLIST_NEW=
! 486: FLIST_UPDATE=
! 487: echo "all: tns" > $MKAKEFILE
! 488: targets=""
! 489: for file in $FLIST
! 490: do
! 491: tn="${file}.tn.jpg"
! 492: if [ ! -f $tn ]
! 493: then
! 494: FLIST_NEW="$FLIST_NEW $file"
! 495: continue
! 496: fi
! 497:
! 498: targets="$targets $tn"
! 499: (
! 500: cat <<MAKE
! 501: $tn: $file
! 502: @echo ${file}
! 503: MAKE
! 504: ) >> $MKAKEFILE
! 505: done
! 506: echo "tns: $targets" >> $MKAKEFILE
! 507: FLIST_UPDATE=$(make -f $MKAKEFILE)
! 508: rm $MKAKEFILE
! 509:
! 510: # update and no new and update images found
! 511: if [ $ARG_UPDATE -eq 1 -a "$FLIST_NEW" = "" -a "$FLIST_UPDATE" = "" ]
! 512: then
! 513: echo nothing to do
! 514: exit 1
! 515: fi
! 516:
! 517: if [ $ARG_UPDATE -eq 1 ]
! 518: then
! 519: echo new images: $FLIST_NEW
! 520: echo update images: $FLIST_UPDATE
! 521: fi
! 522: exit
! 523:
1.1 as 524: # Create make file to rotate und convert all big and thumbnails.
525: # Is needed to define the new real image sizes.
526: echo "all: tns" > $MKAKEFILE
527: targets=""
528: for file in $FLIST
529: do
530: tn="${file}.tn.jpg"
531: big="${file}.big.jpg"
532: targets="$targets $tn"
533:
534: target=
535: if [ $ARG_UPDATE -eq 1 ]
536: then
537: target="$tn: $ME $file"
538: else
539: target="$tn::"
540: fi
541:
542: (
1.5 ! as 543: cat <<MAKE
1.1 as 544: $target
545: $BIN_EXIFAUTOTRAN $file
546: $BIN_CONVERT -verbose -thumbnail ${ARG_TNSIZE}x${ARG_TNSIZE} -quality $ARG_TNQALITY $file $tn
547: $BIN_CONVERT -verbose -thumbnail ${ARG_BIGSIZE}x${ARG_BIGSIZE} -quality $ARG_BIGQALITY $file $big
548: MAKE
549: ) >> $MKAKEFILE
550: done
551: echo "tns: $targets" >> $MKAKEFILE
552:
553: make -f $MKAKEFILE
554: rm $MKAKEFILE
555:
556: # create single html files
557: index=""
558: i=0
559: echo -n "create single html files "
560: for file in $FLIST
561: do
562: h=$i
563: i=$(($i + 1))
564: j=$(($i + 1))
565:
566: tn="${file}.tn.jpg"
567: big="${file}.big.jpg"
568: imglink="${file}.html"
569:
570: if [ $i -ne 1 ]
571: then
572: linkb=$(echo $FLIST | awk "{print \$$h}").html
573: fi
574: linkn=$(echo $FLIST | awk "{print \$$j}")
575: test "$linkn" != "" && linkn="$linkn.html"
576:
577: echo -n .
578: index="$index $(html_tn $tn $imglink)"
579: (
580: html_header
581: html_img $big $ARG_INDEX "$linkb" "$linkn"
582: html_footer
583: ) > $imglink
584: done
585: echo
586:
587: # create html index
588: echo create html index
589: (
590: html_header
591: echo $index
592: echo "<div class='clear'></div>"
593: echo "<div class='c'>$ARG_TITLE $ARG_COPYRIGHT</div>"
594: html_footer
595: ) > $ARG_INDEX