#!/bin/sh ## Script for generating photo gallery website ## ## Usage: ## $ ./gal [PHOTOS DIR] [OUTPUT DIR] ## ## Setting custom title: ## $ TITLE=Title ./gal [AS ABOVE] ## === Customize === QUALITY=70 THUMBNAIL_RESOLUTION=250 RESOLUTION=1500 ## ================= [ -z $1 ] && echo "You need to pass photos dir" && exit 1 [ -z $2 ] && echo "You need to pass output dir" && exit 1 PHOTOS=$1 OUTPUT=$2 TITLE=${TITLE:-$(basename $OUTPUT)} mkdir -p $2/{photos,thumbs} ## Generate index.html menu file cp style.css $OUTPUT chmod 644 $OUTPUT/style.css echo "Generating index.html" cat > $OUTPUT/index.html < $TITLE

$TITLE

Last update: $(date '+%d.%m.%Y')

EOF for f in $PHOTOS/*.{jpg,JPG,jpeg,JPEG,png,PNG}; do filename=$(basename $f) [ -f $f ] && cat >> $OUTPUT/index.html < $filename
EOF done cat >> $OUTPUT/index.html < EOF ## Generate photo_list echo "Generating photo_list" [ -f $OUTPUT/photo_list ] && echo "Replacing existing photo_list" && rm $OUTPUT/photo_list for f in $PHOTOS/*.{jpg,JPG,jpeg,JPEG,png,PNG}; do filename=$(basename $f) [ -f $f ] && cat >> $OUTPUT/photo_list <