Annotation of scripts/pgallery/src/pgallery.sh, revision 1.7
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.7 ! as 8: # $Paefchen: scripts/pgallery/src/pgallery.sh,v 1.6 2012/08/28 12:30:30 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.6 as 22: ARG_INFOFILE=""
23: ARG_MAILTO=""
24: ARG_MAILFROM="PGallery <${USER}@${HOST}>"
25: ARG_URL=
1.7 ! as 26: ARG_EXIF="0x920a 0x829d 0x829a ISO 0x8827 / 0x010f - 0x0110"
1.1 as 27:
28: BIN_CONVERT="/usr/local/bin/convert"
29: BIN_EXIFAUTOTRAN="/usr/local/bin/exifautotran"
30: BIN_IMGINFO="/usr/local/bin/imginfo"
1.6 as 31: BIN_SENDMAIL="/usr/sbin/sendmail"
1.7 ! as 32: BIN_EXIFTRAN="/usr/local/bin/exiftran"
! 33: BIN_EXIF="/usr/local/bin/exif"
1.1 as 34:
35: MKAKEFILE=".htmakefile"
1.5 as 36: VERSION="pgallery-1.1"
1.1 as 37:
38: #
39: # usage()
40: #
41: usage()
42: {
43: cat <<USAGE
44: usage $0: ( [-f <files>] | [-s <suffix>] ) [-d <dir>] [-n <name>]
45: [-t <thumbnail_size>] [-u <thumbnail_quality>]
1.7 ! as 46: [-b <big_size>] [-c <big_quality>] [-l link] [-e <exif>]
1.6 as 47: [-i <index>] [-C <copyright>] [-F <mailfrom>] [-T <mailto>]
48: [-U] | -h | -v
1.1 as 49: Options:
50: -b size size from big images in pixel (default: $ARG_BIGSIZE)
51: -c quality quality from big images 0-100% (default: $ARG_BIGQALITY)
52: -d dir gallery dir (default: $ARG_DIR)
1.7 ! as 53: -e exif list of tags in hex. (default: $ARG_EXIF)
! 54: see: http://www.exiv2.org/tags.html
1.1 as 55: -f files gallery images
56: -h this page
57: -i name index file name (default: $ARG_INDEX)
1.6 as 58: -l url gallery link
1.1 as 59: -n name page title (default: $ARG_TITLE)
60: -s suffix list of suffix. if no \`\`-f'' defined, used to find images
61: in \`\`-d'' directoy. case insensitive
62: (default: $ARG_FILETYPES)
63: -t size size from thumbnail images in pixel (default: $ARG_TNSIZE)
64: -u quality quality from thumbnail images 0-100% (default: $ARG_BIGQALITY)
1.4 as 65: -v print version
66: -C copyright copyright (html) string (default: $ARG_COPYRIGHT)
1.6 as 67: -F from mail sender (default: $ARG_MAILFROM)
1.5 as 68: -I file info text file for pgallery. info file paras prefered.
69: the syntax of the file is MAKE(1)
1.6 as 70: supported variable: TITLE COPYRIGHT INDEX FILETYPES TNSIZE URL
71: TNQALITY BIGSIZE BIGQALITY MAILTO MAILFROM
1.7 ! as 72: EXIF
1.6 as 73: -T mailto send update infos to this address. if not set, no mail delivery
1.1 as 74: -U no update, new calculation of all images.
75: normally only new and modified images will calculated
76: USAGE
77: exit
78: }
79:
80: #
81: # get_my_path()
82: #
83: get_my_path()
84: {
85: current=$(pwd)
86: cd $(dirname $0)
87: echo $(pwd)/$(basename $0)
88: cd "$current"
89: }
90:
91: #
92: # html_header()
93: #
94: html_header()
95: {
96: cat <<HTML
97: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
98: "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
99: <html xmlns="http://www.w3.org/1999/xhtml">
100: <head>
101: <title>$ARG_TITLE</title>
102: <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
103: <style type="text/css">
104: <!--
105: body {
106: background-color: #464646;
107: background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAFgAAABYB\
108: AMAAACDuy0HAAAAG1BMVEX+/v4BAQH///8KCgoDAwN/f3/19fWAgID8/PzhDwT2AAAACXRSTlMFBQUFBQU\
109: FBQWHDtP9AAALwklEQVR4Xg3KOWOyWhAA0Bn2ci57eXEvQY1JCZp8sQTjVoJLTAkaE0swbj/7ve4UB37FL\
110: W4q86Lwwlh86J/ASAkpWaj+Krbb31HzH0Kjc2tIl7SADaWbpZBPE5dds6jJNyNdjAyKWqdroIixWRQIY6E\
111: /kOY7hIciL/ZfrAO3XP/06AuUJ3mSd/z95OB9vIal0DPlaZWHP7RE6DIXjmKqKkuGr+xNZylOnj1GSlUKv\
112: nxZDBOIzTfMe0fJgJ7c/GIIOdUuKxYyBFUOzvY6AC5AXx8R+o5O4S0j0wqBND3ErIYm/XHFbQjtH1MXD5d\
113: Ubp19OFdjkDlys+HSwrBgHRvL9wVN/pi8ViOIwcv/D1GRW6UuDvJLLQA5lCI17iUdsKYpOuYfMATGnpn/Z\
114: s3W6gov51G+/Vs9Ay//we5kh8uwvEPum6o5HkDMDb3ZWunwtq+UzENU8NphDdbvNtKM3knx5gi6UMSQl+e\
115: Gs+27mraDtxeWdH+T62Us/GylEtr7Ct8jlbeXKvAf5onx8D2uVt1J/GblV+XQyKUInOUG44fqjcszK266y\
116: HWAAYG9ekhvy4l4Maa44jYVyV2RFEuS54e2HcswtmNdqR/+V4P0O9e4XnpWgxVSQkNXpYMCxJ4Vel0lmi5\
117: 6jnYIIJAQMndF+zTEiyuj92r3ijJT1O0alPQnLWJvJLR7Xx7Xg9fm9QOqFu8o29m3QQqFwZN4bki/RoprN\
118: tMKKtEET9iMsJyKpkiguAorn2yzkv0wG3M1EEVDJP5VN7muLjYCglzdGQ7boYGgRmorzhRDq83gglgylC+\
119: hBLEyy6ZQWNwCmmqt6PvExAqGEA9V2XIT4/fS+I2cx1n5td85kOCjHfPWTg72FJ/+vKOyggt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X6nwwDva0S1/O8Mlnida69Ph96fuFvCoRMvXnCfsLPPmC/hA5RnMNE4fDK0pVOQ4B\
158: HLaErzv/wD99ABmjNZk0AAAAABJRU5ErkJggg==");
159: margin: 10px auto;
160: font-family: Geneva,Arial,sans-serif;
161: font-size: 12px;
1.2 as 162: text-shadow: 1px 1px 1px #000;
1.7 ! as 163: color: #808080;
1.1 as 164: }
165: div.tn {
166: float: left;
167: width: ${ARG_TNSIZE}px;
168: height: ${ARG_TNSIZE}px;
169: vertical-align:text-top;
170: text-align: center;
171: margin: 4px;
172: }
173: div.tn a {
174: position: relative;
175: display: inline-block;
176: height: ${ARG_TNSIZE}px;
177: }
178: div.tn, div.big {
179: background-color: black;
180: border-width: 1px;
181: border-style: solid;
182: border-color: gray;
183: box-shadow: 1px 1px 2px #000;
184: padding: 1px;
1.4 as 185: border-radius: 3px;
1.1 as 186: }
187: div.tn:hover {
188: background-color: #222;
189: }
190: div.big {
191: display: inline-block;
192: width: ${ARG_BIGSIZE}px;
193: }
194: div.over {
195: width: ${ARG_BIGSIZE}px;
196: position: absolute;
197: top: 30px;
198: padding: 1px;
199: }
200: div.over a.left, div.over a.right {
201: display: block;
1.2 as 202: /* shell fuck of: missing CTLARI (shouldn't happen) - WTF?! */
203: width: $(($ARG_BIGSIZE / 2))px;
1.1 as 204: position: relative;
205: top: 1px;
206: left: 1px;
207: background-repeat: no-repeat;
208: }
209: div.over a.left:hover {
210: background-position: 5% center;
211: background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAB0AAAAwC\
212: AYAAADtoXHnAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAh9JREFUeNrE2L1Lw0A\
213: UAHATSivSZii0ldpBnMU6SgYJpQUJDlk7dLV+LTqIiIv4B7kLolBKQRA6GLqUDMEhqKAlhUIR4125SHo0b\
214: XJ51x68pDSX+3G5I/dyguM4S/MuMfeHIAiQ7Yo+//+OocAYPm+jWEXxg8JC8erCgvt4AXrqgkkUJRRZ6jq\
215: G71EMRcAeil6wWq2uGYZx1ul0jjRNy5Jey6PauKcRJ5NIhklCoaE4QODNYDCwHVJ6vd5HIpE4xNdQxKOiM\
216: 0G3FIvFc4Imo6CBQV3XXwioje5jREOBkiQdE3SLFWUFFXJfaJQVLP2DIWdvFDA+9pYKiMKBAVFYMAAKD85\
217: A+YBTUH6gD8oXnIDyB31QviCFzgekUPxYVe4ghW7ixhRFueQKUmgZN9hut1s0aNv2V6FQOAUBqRvT+IAaX\
218: 6crWZb1hsqQJFfPkPnpJz6YpmnQlXK5XD6TycRIcrUDib7jQ71ev+v3+9/eSqlUKt1qtU4IvIFid2x9jDC\
219: muJE9PG6qql7jcaTHttvt6gh2J1MZYva6ees+d9jnjcQXnoDyh31WGb7wlPWUHzwjc+ADB8iR4OGA2SAsH\
220: CLvhYNDZvgwMMO3THSY8auNBS6xfrVFhZUoaGjYk+qA7DkEgmu12i1Bs1C7K1NhvLviecTLEOhEuFKpXDW\
221: bzcdGo/Egy/KFZzKJPHbMVsiEyVPXTRRPeMdMWMQuqLi0gPInwACOBcZx3lRFMwAAAABJRU5ErkJggg==");
222: }
223: div.over a.right:hover {
224: background-position: 95% center;
225: background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAB0AAAAwC\
226: AYAAADtoXHnAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAiJJREFUeNrE2D1Lw0A\
227: YAOAmlNbBdii0FVM6OEu7SgcJpRUJDlk7dE21uuggIi7iD/IX+AGlFAXBDqVLyVCCBBW0JFhwMN7JHRxnY\
228: 5PcnX3hhSM58nB3+Xhzkud5sf8OiWjLPn2+eGF4gHEChLkOcgUdt0E+isAlhCVAbiGQjGeQ1yBdHjAeKZ7\
229: SCgR1Xc8Nh8M90zQPG42GAo7lQFZBLhOzwSXgKI1kMrk7mUxePBTT6dQB8Dk8B1IHmUbTLrOMFI8WjsIol\
230: 8tHHhW8YRKV0QWNwWDwIBKm0RK8aDqdbouEaRReQBUNkygJV0XCNBojnldh8CxUOOyHCoX/QoXB81AhcBC\
231: UOxwU5QqHQbnBYVFWODLKDEdFo8IanGYWNBSsquoJgkus6C+4UCgcOI7zRsP9fv8OoTWM8qh57mHlaFnWp\
232: 23bFn1SUZQiambm1bphYgMWddlsNp7P51fpk+Px2ETNV1YUf383Qa5BsNfr7adSqQzZyXXd91ardUmUs8x\
233: rWYNrBcD2aDQa0GsJ11fTtDO0ntssd28UcAfXzSxvpLBg5DcSKyhH/cowgVG+p8xg2MqBCximRuIGBq0Gu\
234: YJB6l7u4LwKXwjo9y8jFPT7a6uKBGehqmiQRhO45BAJ0ijcQTGazeaFSJBGl/DUkrsrvMFZa/pzE1UqleN\
235: Op3PV7XZv6vX6KU+QRMkdM3gzFal+TyBvQX7w3DGTFrELKscWEN8CDADBm8pgcciwqgAAAABJRU5ErkJgg\
236: g==");
237: }
238: div.big a {
239: position: relative;
240: display: inline-block;
241: width: ${ARG_BIGSIZE}px;
242: }
243: div.box {
244: text-align: center;
245: width: ${ARG_BIGSIZE}px;
246: margin: auto;
247: }
1.7 ! as 248: div.box div.d {
! 249: width: ${ARG_BIGSIZE}px;
! 250: padding: 5px;
! 251: text-align: center;
! 252: }
! 253: div.box div.i {
1.1 as 254: width: ${ARG_BIGSIZE}px;
255: font-size: 90%;
256: height: 25px;
257: line-height: 25px;
258: position: relative;
259: left: 4px;
260: }
261: body > div.c {
262: text-align: center;
263: font-size: 90%;
264: height: 25px;
265: line-height: 25px;
266: position: relative;
267: margin: 4px;
268: }
269: a img {
270: border-width: 0;
271: }
272: a {
273: }
274: div.nav {
275: width: ${ARG_BIGSIZE}px;
276: height: 20px;
277: }
278: div.nav a {
279: color: #FFF;
280: text-decoration: none;
281: }
282: div.nav a:hover {
283: text-decoration: underline;
284: }
285: div.nav div.top {
286: position: absolute;
287: text-align: center;
1.2 as 288: width: $(($ARG_BIGSIZE - 100))px;
289: margin: 0 50px;
1.1 as 290: }
291: .left {
292: float: left;
293: }
294: .right {
295: float: right;
296: }
297: .clear {
298: clear: both;
299: }
300: -->
301: </style>
302: </head>
303: <body>
304: HTML
305: }
306:
307: #
308: # html_footer()
309: #
310: html_footer()
311: {
312: cat <<HTML
313: </body></html>
314: HTML
315: }
316:
317: #
318: # html_tn()
319: #
320: html_tn()
321: {
322: tn=$1
323: link=$2
324:
325: info=$($BIN_IMGINFO -f $tn)
326: width=$(echo $info | awk '{print $3}')
327: height=$(echo $info | awk '{print $4}')
328: top=$(($(($ARG_TNSIZE - $height)) / 2))
329:
330: cat <<HTML
331: <div class="tn">
332: <a href="$link" style="top:${top}px">
333: <img alt="$tn" width="$width" height="$height" src="$tn" />
334: </a>
335: </div>
336: HTML
337: }
338:
339: #
340: # html_img()
341: #
342: html_img()
343: {
1.7 ! as 344: orig=$1
! 345: img=$2
! 346: link=$3
! 347: linkb=$4
! 348: linkn=$5
1.1 as 349:
1.3 as 350: info=$($BIN_IMGINFO -f $img)
351: width=$(echo $info | awk '{print $3}')
352: height=$(echo $info | awk '{print $4}')
1.1 as 353:
1.7 ! as 354: desc=$(get_exif_desc $orig)
! 355: if [ "$desc" != "" ]
! 356: then
! 357: desc="<div class='d'>$desc</div>"
! 358: fi
! 359:
1.1 as 360: if [ "$linkb" != "" ]
361: then
362: hlinkb="<a href='$linkb'>zurück</a>"
363: olinkb="<a class='left' style='height:${height}px' href='$linkb'></a>"
364: fi
365:
366: if [ "$linkn" != "" ]
367: then
368: hlinkn="<a href="$linkn">weiter</a>"
369: olinkn="<a class='right' style='height:${height}px' href='$linkn'></a>"
370: fi
371:
372: cat <<HTML
373: <div class="box">
374: <div class="nav">
1.2 as 375: <div class="top"><a href="$link">Index</a></div>
1.1 as 376: <div class="left">$hlinkb</div>
377: <div class="right">$hlinkn</div>
378: </div>
379: <div class="big">
1.3 as 380: <img alt="$img" width="$width" height="$height" src="$img" />
1.1 as 381: </div>
1.7 ! as 382: $desc
! 383: <div class="i">
! 384: <div class="left">$(get_exif_info $orig)</div>
! 385: <div class="right">$ARG_TITLE $ARG_COPYRIGHT</div>
1.1 as 386: </div>
387: <div class="over" style='height:${height}px'>
388: $olinkb
389: $olinkn
390: </div>
391: </div>
392: HTML
393: }
394:
395: #
396: # err
397: #
398: err()
399: {
400: echo "$1" >&2
401: exit 1
402: }
403:
1.6 as 404: #
405: # mysendmail()
406: #
407: mysendmail()
408: {
409: subject=$1
410: (
411: cat <<MAIL
412: From: $ARG_MAILFROM
413: To: $ARG_MAILTO
414: Subject: $subject
415: Content-Type: text/plain; charset=iso-8859-1
416: X-Mailer: $VERSION
417:
418: $(cat)
419: MAIL
420: ) | $BIN_SENDMAIL -t
421: }
1.1 as 422:
1.7 ! as 423: #
! 424: # get_exif_desc()
! 425: #
! 426: get_exif_desc()
! 427: {
! 428: img=$1
! 429: $BIN_EXIF --ifd=0 --tag=0x010e -m $img 2> /dev/null | iconv -t ISO-8859-1 -f UTF-8 | while read line
! 430: do
! 431: echo "$line<br />"
! 432: done
! 433: }
! 434:
! 435: #
! 436: # get_exif_value()
! 437: #
! 438: get_exif_value()
! 439: {
! 440: img=$1
! 441: hex=$2
! 442: $BIN_EXIFTRAN -d $img | grep $hex | sed -E 's/^.{45}//'
! 443: }
! 444:
! 445: #
! 446: # get_exif_info()
! 447: #
! 448: get_exif_info()
! 449: {
! 450: img=$1
! 451: exifinfo=
! 452: for exif in $ARG_EXIF
! 453: do
! 454: if echo $exif | grep -q -E '0x[[:alnum:]]{4}'
! 455: then
! 456: exifinfo="$exifinfo$(get_exif_value $img $exif) "
! 457: else
! 458: exifinfo="$exifinfo$exif "
! 459: fi
! 460: done
! 461: echo $exifinfo
! 462: }
! 463:
1.1 as 464: # parse args
465: while [ "$1" != "" ]
466: do
467: arg=$1
468: shift
469: case $arg in
470: -h)
1.6 as 471: usage;;
1.1 as 472: -n)
473: ARG_TITLE=$1
1.6 as 474: shift;;
1.1 as 475: -t)
476: ARG_TNSIZE=$1
1.6 as 477: shift;;
1.1 as 478: -u)
479: ARG_TNQALITY=$1
1.6 as 480: shift;;
1.1 as 481: -b)
482: ARG_BIGSIZE=$1
1.6 as 483: shift;;
1.1 as 484: -c)
485: ARG_BIGQALITY=$1
1.6 as 486: shift;;
1.1 as 487: -f)
488: ARG_FILES=$1
1.6 as 489: shift;;
490: -l)
491: ARG_URL=$1
492: shift;;
1.1 as 493: -s)
494: ARG_FILETYPES=$1
1.6 as 495: shift;;
1.1 as 496: -d)
497: ARG_DIR=$1
1.6 as 498: shift;;
1.7 ! as 499: -e)
! 500: ARG_EXIF=$1
! 501: shift;;
1.1 as 502: -C)
503: ARG_COPYRIGHT=$1
1.6 as 504: shift;;
505: -F)
506: ARG_MAILFROM=$1
507: shift;;
1.5 as 508: -I)
509: ARG_INFOFILE=$1
1.6 as 510: shift;;
511: -T)
512: ARG_MAILTO=$1
513: shift;;
1.1 as 514: -U)
1.6 as 515: ARG_UPDATE=0;;
1.1 as 516: -v)
517: echo $VERSION
1.6 as 518: exit;;
1.1 as 519: *)
520: echo "unknown argument $arg"
521: exit
522: esac
523: done
524:
1.5 as 525: # parese info file
526: if [ "$ARG_INFOFILE" != "" ]
527: then
528: test -f $ARG_INFOFILE || err "info file not found \`\`$ARG_INFOFILE''"
1.6 as 529: for n in TITLE COPYRIGHT INDEX FILETYPES TNSIZE TNQALITY BIGSIZE \
1.7 ! as 530: BIGQALITY MAILTO MAILFROM URL EXIF
1.5 as 531: do
532: v=$(make -f $ARG_INFOFILE -V$n)
533: test "$v" = "" && continue
534: eval "ARG_$n='$v'"
535: done
536: fi
537:
1.6 as 538: # go to gallery directory
1.1 as 539: MY=$(get_my_path)
540: cd "$ARG_DIR" || exit 1
541:
1.6 as 542: # fix url
543: if [ "$ARG_URL" != "" ]
544: then
545: echo "$ARG_URL" | grep -q '/$' || ARG_URL="${ARG_URL}/"
546: fi
547:
1.1 as 548: # if no images defined, find files
549: if [ "$ARG_FILES" = "" -a "$ARG_FILETYPES" != "" ]
550: then
551: match=
552: for type in $ARG_FILETYPES
553: do
554: match="$match *.$(echo $type | tr '[:lower:]' '[:upper:]')"
555: match="$match *.$(echo $type | tr '[:upper:]' '[:lower:]')"
556: done
557: ARG_FILES=$(cd $ARG_DIR && ls $match 2>/dev/null)
558: fi
559:
560: # Filter big and thumbnails
561: echo -n "find images"
562: FLIST=
563: for file in $ARG_FILES
564: do
565: test $(echo $file | grep -E '\.(tn|big)\.jpg$') && continue
566: FLIST="$FLIST $file"
567: echo -n " $file"
568: done
569: echo
570:
571: test $(echo $FLIST | wc -w) -eq 0 && err "error: no image found in \`\`$ARG_DIR''"
572:
1.5 as 573: # find new and to update images
574: FLIST_NEW=
575: FLIST_UPDATE=
576: echo "all: tns" > $MKAKEFILE
577: targets=""
578: for file in $FLIST
579: do
580: tn="${file}.tn.jpg"
581: if [ ! -f $tn ]
582: then
583: FLIST_NEW="$FLIST_NEW $file"
584: continue
585: fi
586:
587: targets="$targets $tn"
588: (
589: cat <<MAKE
590: $tn: $file
591: @echo ${file}
592: MAKE
593: ) >> $MKAKEFILE
594: done
595: echo "tns: $targets" >> $MKAKEFILE
596: FLIST_UPDATE=$(make -f $MKAKEFILE)
597: rm $MKAKEFILE
598:
599: # update and no new and update images found
600: if [ $ARG_UPDATE -eq 1 -a "$FLIST_NEW" = "" -a "$FLIST_UPDATE" = "" ]
601: then
602: echo nothing to do
603: exit 1
604: fi
605:
606: if [ $ARG_UPDATE -eq 1 ]
607: then
608: echo new images: $FLIST_NEW
609: echo update images: $FLIST_UPDATE
610: fi
611:
1.1 as 612: # Create make file to rotate und convert all big and thumbnails.
613: # Is needed to define the new real image sizes.
614: echo "all: tns" > $MKAKEFILE
615: targets=""
616: for file in $FLIST
617: do
618: tn="${file}.tn.jpg"
619: big="${file}.big.jpg"
620: targets="$targets $tn"
621:
622: target=
623: if [ $ARG_UPDATE -eq 1 ]
624: then
625: target="$tn: $ME $file"
626: else
627: target="$tn::"
628: fi
629:
630: (
1.5 as 631: cat <<MAKE
1.1 as 632: $target
633: $BIN_EXIFAUTOTRAN $file
634: $BIN_CONVERT -verbose -thumbnail ${ARG_TNSIZE}x${ARG_TNSIZE} -quality $ARG_TNQALITY $file $tn
635: $BIN_CONVERT -verbose -thumbnail ${ARG_BIGSIZE}x${ARG_BIGSIZE} -quality $ARG_BIGQALITY $file $big
636: MAKE
637: ) >> $MKAKEFILE
638: done
639: echo "tns: $targets" >> $MKAKEFILE
640:
641: make -f $MKAKEFILE
642: rm $MKAKEFILE
643:
644: # create single html files
645: index=""
646: i=0
647: echo -n "create single html files "
648: for file in $FLIST
649: do
650: h=$i
651: i=$(($i + 1))
652: j=$(($i + 1))
653:
654: tn="${file}.tn.jpg"
655: big="${file}.big.jpg"
656: imglink="${file}.html"
657:
658: if [ $i -ne 1 ]
659: then
660: linkb=$(echo $FLIST | awk "{print \$$h}").html
661: fi
662: linkn=$(echo $FLIST | awk "{print \$$j}")
663: test "$linkn" != "" && linkn="$linkn.html"
664:
665: echo -n .
666: index="$index $(html_tn $tn $imglink)"
667: (
668: html_header
1.7 ! as 669: html_img $file $big $ARG_INDEX "$linkb" "$linkn"
1.1 as 670: html_footer
671: ) > $imglink
672: done
673: echo
674:
675: # create html index
676: echo create html index
677: (
678: html_header
679: echo $index
680: echo "<div class='clear'></div>"
681: echo "<div class='c'>$ARG_TITLE $ARG_COPYRIGHT</div>"
682: html_footer
683: ) > $ARG_INDEX
1.6 as 684:
685:
686: test "$ARG_MAILTO" = "" && exit 0
687:
688: # send info mail
689: if [ "$FLIST_NEW" != "" -o "$FLIST_UPDATE" != "" ]
690: then
691: echo "send mail to $ARG_MAILTO"
692: (
693: echo "Hallo,"
694: echo
695: echo -n "the gallery $ARG_TITLE has been updated"
696: if [ "$ARG_URL" != "" ]
697: then
698: echo ":"
699: echo $ARG_URL
700: else
701: echo "."
702: fi
703:
704: suffix=
705: test "$ARG_URL" != "" && suffix=.html
706:
707: if [ "$FLIST_NEW" != "" ]
708: then
709: echo
710: echo "add pictures:"
711: for file in $FLIST_NEW
712: do
713: echo "- ${ARG_URL}${file}${suffix}"
714: done
715: fi
716:
717: if [ "$FLIST_UPDATE" != "" ]
718: then
719: echo
720: echo "update pictures:"
721: for file in $FLIST_UPDATE
722: do
723: echo "- ${ARG_URL}${file}${suffix}"
724: done
725: fi
726: ) | mysendmail "PGallery Update: $ARG_TITLE"
727: fi