Annotation of scripts/pgallery/src/pgallery.sh, revision 1.1
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: #
! 8: # $Paefchen$
! 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+HSwrBgHRvL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WcD/PX6LaGd25CuN\
! 131: HG/vgeIB1kcpCme+J8idlcjfBALAJSggznsGHGOAJgdGduMnZg+bAaeGASGV9bh/X2wPsVTmBLxmTTQsBG\
! 132: FkEOkZJTsGAm+HrtMDbWwvTXOutX1u7BxIq9Xib6DkFMbUitNdrYsULkahsAhBEh9FjdzL9BNARxTSr7T3\
! 133: u1rE+IWUmCIpwTZHZCu5l9THCuCcOhZqfekuQxjQ7EoyGUJAwCv/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;
! 143: }
! 144: div.tn {
! 145: float: left;
! 146: width: ${ARG_TNSIZE}px;
! 147: height: ${ARG_TNSIZE}px;
! 148: vertical-align:text-top;
! 149: text-align: center;
! 150: margin: 4px;
! 151: }
! 152: div.tn a {
! 153: position: relative;
! 154: display: inline-block;
! 155: height: ${ARG_TNSIZE}px;
! 156: }
! 157: div.tn, div.big {
! 158: background-color: black;
! 159: border-width: 1px;
! 160: border-style: solid;
! 161: border-color: gray;
! 162: box-shadow: 1px 1px 2px #000;
! 163: padding: 1px;
! 164: }
! 165: div.tn:hover {
! 166: background-color: #222;
! 167: }
! 168: div.big {
! 169: display: inline-block;
! 170: width: ${ARG_BIGSIZE}px;
! 171: }
! 172: div.over {
! 173: width: ${ARG_BIGSIZE}px;
! 174: position: absolute;
! 175: top: 30px;
! 176: padding: 1px;
! 177: }
! 178: div.over a.left, div.over a.right {
! 179: display: block;
! 180: position: relative;
! 181: top: 1px;
! 182: left: 1px;
! 183: background-repeat: no-repeat;
! 184: width: $(($ARG_BIGSIZE / 2))px;
! 185: }
! 186: div.over a.left:hover {
! 187: background-position: 5% center;
! 188: background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAB0AAAAwC\
! 189: AYAAADtoXHnAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAh9JREFUeNrE2L1Lw0A\
! 190: UAHATSivSZii0ldpBnMU6SgYJpQUJDlk7dLV+LTqIiIv4B7kLolBKQRA6GLqUDMEhqKAlhUIR4125SHo0b\
! 191: XJ51x68pDSX+3G5I/dyguM4S/MuMfeHIAiQ7Yo+//+OocAYPm+jWEXxg8JC8erCgvt4AXrqgkkUJRRZ6jq\
! 192: G71EMRcAeil6wWq2uGYZx1ul0jjRNy5Jey6PauKcRJ5NIhklCoaE4QODNYDCwHVJ6vd5HIpE4xNdQxKOiM\
! 193: 0G3FIvFc4Imo6CBQV3XXwioje5jREOBkiQdE3SLFWUFFXJfaJQVLP2DIWdvFDA+9pYKiMKBAVFYMAAKD85\
! 194: A+YBTUH6gD8oXnIDyB31QviCFzgekUPxYVe4ghW7ixhRFueQKUmgZN9hut1s0aNv2V6FQOAUBqRvT+IAaX\
! 195: 6crWZb1hsqQJFfPkPnpJz6YpmnQlXK5XD6TycRIcrUDib7jQ71ev+v3+9/eSqlUKt1qtU4IvIFid2x9jDC\
! 196: muJE9PG6qql7jcaTHttvt6gh2J1MZYva6ees+d9jnjcQXnoDyh31WGb7wlPWUHzwjc+ADB8iR4OGA2SAsH\
! 197: CLvhYNDZvgwMMO3THSY8auNBS6xfrVFhZUoaGjYk+qA7DkEgmu12i1Bs1C7K1NhvLviecTLEOhEuFKpXDW\
! 198: bzcdGo/Egy/KFZzKJPHbMVsiEyVPXTRRPeMdMWMQuqLi0gPInwACOBcZx3lRFMwAAAABJRU5ErkJggg==");
! 199: }
! 200: div.over a.right:hover {
! 201: background-position: 95% center;
! 202: background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAB0AAAAwC\
! 203: AYAAADtoXHnAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAiJJREFUeNrE2D1Lw0A\
! 204: YAOAmlNbBdii0FVM6OEu7SgcJpRUJDlk7dE21uuggIi7iD/IX+AGlFAXBDqVLyVCCBBW0JFhwMN7JHRxnY\
! 205: 5PcnX3hhSM58nB3+Xhzkud5sf8OiWjLPn2+eGF4gHEChLkOcgUdt0E+isAlhCVAbiGQjGeQ1yBdHjAeKZ7\
! 206: SCgR1Xc8Nh8M90zQPG42GAo7lQFZBLhOzwSXgKI1kMrk7mUxePBTT6dQB8Dk8B1IHmUbTLrOMFI8WjsIol\
! 207: 8tHHhW8YRKV0QWNwWDwIBKm0RK8aDqdbouEaRReQBUNkygJV0XCNBojnldh8CxUOOyHCoX/QoXB81AhcBC\
! 208: UOxwU5QqHQbnBYVFWODLKDEdFo8IanGYWNBSsquoJgkus6C+4UCgcOI7zRsP9fv8OoTWM8qh57mHlaFnWp\
! 209: 23bFn1SUZQiambm1bphYgMWddlsNp7P51fpk+Px2ETNV1YUf383Qa5BsNfr7adSqQzZyXXd91ardUmUs8x\
! 210: rWYNrBcD2aDQa0GsJ11fTtDO0ntssd28UcAfXzSxvpLBg5DcSKyhH/cowgVG+p8xg2MqBCximRuIGBq0Gu\
! 211: YJB6l7u4LwKXwjo9y8jFPT7a6uKBGehqmiQRhO45BAJ0ijcQTGazeaFSJBGl/DUkrsrvMFZa/pzE1UqleN\
! 212: Op3PV7XZv6vX6KU+QRMkdM3gzFal+TyBvQX7w3DGTFrELKscWEN8CDADBm8pgcciwqgAAAABJRU5ErkJgg\
! 213: g==");
! 214: }
! 215: div.big a {
! 216: position: relative;
! 217: display: inline-block;
! 218: width: ${ARG_BIGSIZE}px;
! 219: }
! 220: div.box {
! 221: text-align: center;
! 222: width: ${ARG_BIGSIZE}px;
! 223: margin: auto;
! 224: }
! 225: div.box div.c {
! 226: width: ${ARG_BIGSIZE}px;
! 227: text-align: right;
! 228: font-size: 90%;
! 229: color: #808080;
! 230: height: 25px;
! 231: line-height: 25px;
! 232: position: relative;
! 233: left: 4px;
! 234: text-shadow: 1px 1px 1px #000;
! 235: }
! 236: body > div.c {
! 237: text-align: center;
! 238: font-size: 90%;
! 239: color: #808080;
! 240: height: 25px;
! 241: line-height: 25px;
! 242: position: relative;
! 243: text-shadow: 1px 1px 1px #000;
! 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;
! 265: width: ${ARG_BIGSIZE}px;
! 266: }
! 267: .left {
! 268: float: left;
! 269: }
! 270: .right {
! 271: float: right;
! 272: }
! 273: .clear {
! 274: clear: both;
! 275: }
! 276: -->
! 277: </style>
! 278: </head>
! 279: <body>
! 280: HTML
! 281: }
! 282:
! 283: #
! 284: # html_footer()
! 285: #
! 286: html_footer()
! 287: {
! 288: cat <<HTML
! 289: </body></html>
! 290: HTML
! 291: }
! 292:
! 293: #
! 294: # html_tn()
! 295: #
! 296: html_tn()
! 297: {
! 298: tn=$1
! 299: link=$2
! 300:
! 301: info=$($BIN_IMGINFO -f $tn)
! 302: width=$(echo $info | awk '{print $3}')
! 303: height=$(echo $info | awk '{print $4}')
! 304: top=$(($(($ARG_TNSIZE - $height)) / 2))
! 305:
! 306: cat <<HTML
! 307: <div class="tn">
! 308: <a href="$link" style="top:${top}px">
! 309: <img alt="$tn" width="$width" height="$height" src="$tn" />
! 310: </a>
! 311: </div>
! 312: HTML
! 313: }
! 314:
! 315: #
! 316: # html_img()
! 317: #
! 318: html_img()
! 319: {
! 320: img=$1
! 321: link=$2
! 322: linkb=$3
! 323: linkn=$4
! 324:
! 325: height=$($BIN_IMGINFO -f $img | awk '{print $4}')
! 326:
! 327: if [ "$linkb" != "" ]
! 328: then
! 329: hlinkb="<a href='$linkb'>zurück</a>"
! 330: olinkb="<a class='left' style='height:${height}px' href='$linkb'></a>"
! 331: fi
! 332:
! 333: if [ "$linkn" != "" ]
! 334: then
! 335: hlinkn="<a href="$linkn">weiter</a>"
! 336: olinkn="<a class='right' style='height:${height}px' href='$linkn'></a>"
! 337: fi
! 338:
! 339: cat <<HTML
! 340: <div class="box">
! 341: <div class="nav">
! 342: <div class="left">$hlinkb</div>
! 343: <div class="top"><a href="$link">Index</a></div>
! 344: <div class="right">$hlinkn</div>
! 345: </div>
! 346: <div class="big">
! 347: <img src="$img" />
! 348: </div>
! 349: <div class="c">
! 350: $ARG_TITLE $ARG_COPYRIGHT
! 351: </div>
! 352: <div class="over" style='height:${height}px'>
! 353: $olinkb
! 354: $olinkn
! 355: </div>
! 356: </div>
! 357: HTML
! 358: }
! 359:
! 360: #
! 361: # err
! 362: #
! 363: err()
! 364: {
! 365: echo "$1" >&2
! 366: exit 1
! 367: }
! 368:
! 369:
! 370: # parse args
! 371: while [ "$1" != "" ]
! 372: do
! 373: arg=$1
! 374: shift
! 375: case $arg in
! 376: -h)
! 377: usage
! 378: ;;
! 379: -n)
! 380: ARG_TITLE=$1
! 381: shift
! 382: ;;
! 383: -t)
! 384: ARG_TNSIZE=$1
! 385: shift
! 386: ;;
! 387: -u)
! 388: ARG_TNQALITY=$1
! 389: shift
! 390: ;;
! 391: -b)
! 392: ARG_BIGSIZE=$1
! 393: shift
! 394: ;;
! 395: -c)
! 396: ARG_BIGQALITY=$1
! 397: shift
! 398: ;;
! 399: -f)
! 400: ARG_FILES=$1
! 401: shift
! 402: ;;
! 403: -s)
! 404: ARG_FILETYPES=$1
! 405: shift
! 406: ;;
! 407: -d)
! 408: ARG_DIR=$1
! 409: shift
! 410: ;;
! 411: -C)
! 412: ARG_COPYRIGHT=$1
! 413: shift
! 414: ;;
! 415: -U)
! 416: ARG_UPDATE=0
! 417: ;;
! 418: -v)
! 419: echo $VERSION
! 420: exit
! 421: ;;
! 422: *)
! 423: echo "unknown argument $arg"
! 424: exit
! 425: esac
! 426: done
! 427:
! 428: MY=$(get_my_path)
! 429: cd "$ARG_DIR" || exit 1
! 430:
! 431: # if no images defined, find files
! 432: if [ "$ARG_FILES" = "" -a "$ARG_FILETYPES" != "" ]
! 433: then
! 434: match=
! 435: for type in $ARG_FILETYPES
! 436: do
! 437: match="$match *.$(echo $type | tr '[:lower:]' '[:upper:]')"
! 438: match="$match *.$(echo $type | tr '[:upper:]' '[:lower:]')"
! 439: done
! 440: ARG_FILES=$(cd $ARG_DIR && ls $match 2>/dev/null)
! 441: fi
! 442:
! 443: # Filter big and thumbnails
! 444: echo -n "find images"
! 445: FLIST=
! 446: for file in $ARG_FILES
! 447: do
! 448: test $(echo $file | grep -E '\.(tn|big)\.jpg$') && continue
! 449: FLIST="$FLIST $file"
! 450: echo -n " $file"
! 451: done
! 452: echo
! 453:
! 454: test $(echo $FLIST | wc -w) -eq 0 && err "error: no image found in \`\`$ARG_DIR''"
! 455:
! 456: # Create make file to rotate und convert all big and thumbnails.
! 457: # Is needed to define the new real image sizes.
! 458: echo "all: tns" > $MKAKEFILE
! 459: targets=""
! 460: for file in $FLIST
! 461: do
! 462: tn="${file}.tn.jpg"
! 463: big="${file}.big.jpg"
! 464: targets="$targets $tn"
! 465:
! 466: target=
! 467: if [ $ARG_UPDATE -eq 1 ]
! 468: then
! 469: target="$tn: $ME $file"
! 470: else
! 471: target="$tn::"
! 472: fi
! 473:
! 474: (
! 475: cat <<MAKE
! 476: $target
! 477: $BIN_EXIFAUTOTRAN $file
! 478: $BIN_CONVERT -verbose -thumbnail ${ARG_TNSIZE}x${ARG_TNSIZE} -quality $ARG_TNQALITY $file $tn
! 479: $BIN_CONVERT -verbose -thumbnail ${ARG_BIGSIZE}x${ARG_BIGSIZE} -quality $ARG_BIGQALITY $file $big
! 480: MAKE
! 481: ) >> $MKAKEFILE
! 482: done
! 483: echo "tns: $targets" >> $MKAKEFILE
! 484:
! 485: make -f $MKAKEFILE
! 486: rm $MKAKEFILE
! 487:
! 488: # create single html files
! 489: index=""
! 490: i=0
! 491: echo -n "create single html files "
! 492: for file in $FLIST
! 493: do
! 494: h=$i
! 495: i=$(($i + 1))
! 496: j=$(($i + 1))
! 497:
! 498: tn="${file}.tn.jpg"
! 499: big="${file}.big.jpg"
! 500: imglink="${file}.html"
! 501:
! 502: if [ $i -ne 1 ]
! 503: then
! 504: linkb=$(echo $FLIST | awk "{print \$$h}").html
! 505: fi
! 506: linkn=$(echo $FLIST | awk "{print \$$j}")
! 507: test "$linkn" != "" && linkn="$linkn.html"
! 508:
! 509: echo -n .
! 510: index="$index $(html_tn $tn $imglink)"
! 511: (
! 512: html_header
! 513: html_img $big $ARG_INDEX "$linkb" "$linkn"
! 514: html_footer
! 515: ) > $imglink
! 516: done
! 517: echo
! 518:
! 519: # create html index
! 520: echo create html index
! 521: (
! 522: html_header
! 523: echo $index
! 524: echo "<div class='clear'></div>"
! 525: echo "<div class='c'>$ARG_TITLE $ARG_COPYRIGHT</div>"
! 526: html_footer
! 527: ) > $ARG_INDEX