summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/photobook/scripts/make-spreads.sh
diff options
context:
space:
mode:
Diffstat (limited to 'macros/latex/contrib/photobook/scripts/make-spreads.sh')
-rw-r--r--macros/latex/contrib/photobook/scripts/make-spreads.sh78
1 files changed, 54 insertions, 24 deletions
diff --git a/macros/latex/contrib/photobook/scripts/make-spreads.sh b/macros/latex/contrib/photobook/scripts/make-spreads.sh
index 57be2ff448..05979ae03d 100644
--- a/macros/latex/contrib/photobook/scripts/make-spreads.sh
+++ b/macros/latex/contrib/photobook/scripts/make-spreads.sh
@@ -18,12 +18,12 @@ shopt -s nullglob extglob
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#
# Template structure:
-# templates/
+# $TEMPLATE_DIR/
# spread.tex
# imagepage.tex
# textpage.tex
# ...
-# captions/
+# $CAPTION_DIR/
# <image>.txt
# image caption.
# this is separated to decouple caption writing from the
@@ -131,29 +131,45 @@ shopt -s nullglob extglob
#
#
#----------------------------------------------------------------------
-
# load config...
+
CONFIG=${CONFIG:=$(basename ${0%.*}).cfg}
+# prepend CFG_ to settings in config...
+# NOTE: this is done to prevent them overriding the environment...
[ -e $CONFIG ] \
- && source "$CONFIG"
+ && eval $(cat "$CONFIG" \
+ | sed -e 's/^\(\s*\)\([A-Z_]\+=\)/\1CFG_\2/')
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# defaults...
+#
# NOTE: all of these options can be either set in the $CONFIG file or
# set in the script env.
# NOTE: env takes priority over $CONFIG
# if set add pdf annotations of paths to each image...
+ANOTATE_IMAGE_PATHS=${ANOTATE_IMAGE_PATHS:=$CFG_ANOTATE_IMAGE_PATHS}
ANOTATE_IMAGE_PATHS=${ANOTATE_IMAGE_PATHS:=}
# supported formats/extensions...
+TEXT_FORMATS=${TEXT_FORMATS:=$CFG_TEXT_FORMATS}
TEXT_FORMATS=${TEXT_FORMATS:=txt}
+
+IMAGE_FORMATS=${IMAGE_FORMATS:=$CFG_IMAGE_FORMATS}
IMAGE_FORMATS=${IMAGE_FORMATS:=jpeg|jpg|png|pdf|svg|eps}
+
+SPREADS_DIR=${SPREADS_DIR:=$CFG_SPREADS_DIR}
SPREADS_DIR=${SPREADS_DIR:=spreads/}
+
+IMAGE_HIRES_DIR=${IMAGE_HIRES_DIR:=$CFG_IMAGE_HIRES_DIR}
IMAGE_HIRES_DIR=${IMAGE_HIRES_DIR:=}
+
+CAPTION_DIR=${CAPTION_DIR:=$CFG_CAPTION_DIR}
CAPTION_DIR=${CAPTION_DIR:=captions/}
+
+TEMPLATE_DIR=${TEMPLATE_DIR:=$CFG_TEMPLATE_DIR}
TEMPLATE_DIR=${TEMPLATE_DIR:=templates/}
# Default templates
@@ -161,18 +177,30 @@ TEMPLATE_DIR=${TEMPLATE_DIR:=templates/}
# page components...
# page templates...
+EMPTY_PAGE=${EMPTY_PAGE:=$CFG_EMPTY_PAGE}
EMPTY_PAGE=${EMPTY_PAGE:=emptypage}
+
+TEXT_PAGE=${TEXT_PAGE:=$CFG_TEXT_PAGE}
TEXT_PAGE=${TEXT_PAGE:=textpage}
+
+IMAGE_PAGE=${IMAGE_PAGE:=$CFG_IMAGE_PAGE}
IMAGE_PAGE=${IMAGE_PAGE:=imagepage}
# dynamic spread templates...
# NOTE: the index here corresponds to the number of images found in a
# spread directory...
if [ ${#IMAGE_SPREAD[@]} = 0 ] ; then
- IMAGE_SPREAD=(
- [0]=text-spread
- [2]=image-image
- )
+ if ! [ ${#CFG_IMAGE_SPREAD[@]} = 0 ] ; then
+ IMAGE_SPREAD=()
+ for i in ${!CFG_IMAGE_SPREAD[@]} ; do
+ IMAGE_SPREAD[$i]=${CFG_IMAGE_SPREAD[$i]}
+ done
+ else
+ IMAGE_SPREAD=(
+ [0]=text-spread
+ [2]=image-image
+ )
+ fi
fi
@@ -188,17 +216,18 @@ printhelp(){
echo
echo "Arguments:"
echo " -h --help - print this help and exit."
+ echo " -c PATH - load configuration from PATH."
echo " -a --annotate"
echo " - add annotations with image paths to pages."
- echo " --templates=PATH"
+ echo " --templates PATH"
echo " - path to search for templates (default: $TEMPLATE_DIR)."
- echo " --single-image-tpl=NAME"
+ echo " --single-image-tpl NAME"
echo " - single image default template (default: ${IMAGE_SPREAD[1]})."
- echo " --double-image-tpl=NAME"
+ echo " --double-image-tpl NAME"
echo " - double image default template (default: ${IMAGE_SPREAD[2]})."
- echo " --text-spread-tpl=NAME"
+ echo " --text-spread-tpl NAME"
echo " - text spread default template (default: ${IMAGE_SPREAD[0]})."
- echo " --captions=PATH"
+ echo " --captions PATH"
echo " - path to search for captions (default: $CAPTION_DIR)."
echo
echo "Parameters:"
@@ -248,31 +277,32 @@ while true ; do
ANOTATE_IMAGE_PATHS=1
shift
;;
+ -c)
+ $CONFIG="$2"
+ [ -e "$CONFIG" ] \
+ && source "$CONFIG"
+ shift 2
+ ;;
--templates)
TEMPLATE_DIR=$2
- shift
- shift
+ shift 2
;;
--single-image-tpl)
IMAGE_SPREAD[1]=$2
- shift
- shift
+ shift 2
;;
--double-image-tpl)
IMAGE_SPREAD[2]=$2
- shift
- shift
+ shift 2
;;
--text-spread-tpl)
IMAGE_SPREAD[0]=$2
- shift
- shift
+ shift 2
;;
--captions)
CAPTION_DIR=$2
- shift
- shift
+ shift 2
;;
# handle unknown options...
@@ -289,7 +319,7 @@ done
if [ -z $1 ] ; then
- SPREADS_DIR=pages/
+ SPREADS_DIR=spreads/
else
SPREADS_DIR=$1/
fi