#!/bin/bash #---------------------------------------------------- # Version: 0.2.0 # Author: Florian "Bluewind" Pritz # # Licensed under WTFPL v2 # (see COPYING for full license text) # #---------------------------------------------------- # put images in folder "foo" and run "$0 foo" #---------------------------------------------------- startdir="$PWD" datadir="$(dirname "$0")/generate_gallery.d" html_template="$datadir/template.html" tempfile=$(mktemp "/tmp/image-gallery.XXXXXX") for i in "$@"; do pushd "$i" &>/dev/null echo > $tempfile for img in *; do filename="$(basename "$img")" pushd "$(dirname "$img")" &>/dev/null mkdir -p thumbs if file -b --mime-type "$img" | grep -q "image/.*"; then if [ ! -e "thumbs/$filename" ]; then echo "processing: $i/$img" convert "$filename" -thumbnail 200x200 "thumbs/$filename" fi echo "
" \ " " \ " \"\"" \ " " \ "
" | sed -r 's/\/\//\//g' >> $tempfile else echo "ignoring non-image: $i/$img" fi popd &>/dev/null done cd "$startdir" sed -r \ -e "/%%CONTENT%%/r $tempfile" \ -e '/%%CONTENT/d' \ "$html_template" > "$i/index.html" cp -r "$datadir/lytebox" "$i" popd &>/dev/null done rm $tempfile