Support CLI Options

This commit is contained in:
sh+git@codevoid.de 2019-10-27 13:42:02 +00:00
parent 7f6d35f9b8
commit 96d91a9aeb
2 changed files with 39 additions and 4 deletions

View File

@ -1,6 +1,6 @@
all:
./mkpicindex.sh > index.html.tmp && mv index.html.tmp index.html
static:
./mkpicindex-static.sh 0 > index.html.tmp && mv index.html.tmp index.html
./mkpicindex-static.sh > index.html.tmp && mv index.html.tmp index.html
clean:
rm -rf index.html.tmp index.html style.css justify.js LICENSE

View File

@ -11,8 +11,8 @@ printf '%s' \
# CONFIGURE
TITLE="My Gallery" # browser title
WIDTH=1000 # how wide will the gallery be
ROW_HEIGHT=150 # how high will the justified rows be?
WIDTH=850 # how wide will the gallery be
ROW_HEIGHT=180 # how high will the justified rows be?
THUMB_QUALITY=83 # quality for thumbnails
THUMB_PATH="thm" # relative path to thumbnail folder
THUMB_PADDING="6" # image padding
@ -21,6 +21,41 @@ THUMB_PADDING="6" # image padding
DEBUG=0 # debug output
THREADS=4
# PRINT HELP / USAGE TEXT
usage() {
printf '%s\n' \
'Usage: mkpicindex [option] > outfile.html
Options:
-t "My Gallery" - Title
-w 850 - Width
-h 180 - Row height
-q 83 - Thumbnail quality
-b 6 - Thumbnail border
-p 8 - Max convert processes
-d - Debug mode
-h - This help
'
exit 2
}
# OVERIDE DEFAULTS
while getopts 't:w:h:b:q:p:d' c
do
case $c in
t) TITLE="$OPTARG" ;;
w) WIDTH="$OPTARG" ;;
h) ROW_HEIGHT="$OPTARG" ;;
q) QUALITY="$OPTARG" ;;
b) THUMB_PADDING="$OPTARG" ;;
p) THREADS="$OPTARG" ;;
d) DEBUG=1 ;;
?|*) usage; ;;
esac
done
# PRINT USAGE IF OUTPUT IS NOT REDIRECTED
[ "$DEBUG" != 1 ] && test -t 1 && usage;
# GLOBAL TMP VARIABLES
G_ROW_WIDTH=0 # combined pic width < WIDTH @ ROW_HEIGHT
G_ROW_FILES="" # pipe separated files < WIDTH
@ -139,7 +174,7 @@ printf '%s\n' \
'<html>
<head>
<meta name="viewport" content="width=device-width">
<title>My Gallery</title>
<title>'"$TITLE"'</title>
<style>
html {
background: black;