From b8619f8d0b401da1d0305e58de51e2b9cc819b55 Mon Sep 17 00:00:00 2001 From: Matteo Cypriani Date: Fri, 6 Oct 2017 10:31:03 -0400 Subject: [PATCH] tiff-batch-convert: quality is now an argument --- graphics/README.md | 14 ++++++++++---- graphics/tiff-batch-convert.sh | 33 ++++++++++++++++----------------- 2 files changed, 26 insertions(+), 21 deletions(-) diff --git a/graphics/README.md b/graphics/README.md index 1378137..225518f 100644 --- a/graphics/README.md +++ b/graphics/README.md @@ -28,7 +28,12 @@ smartphone. Usage: - tiff-batch-convert.sh [ALBUM2 [...]] + tiff-batch-convert.sh [ALBUM2 [...]] + + impacts the resolution of the converted pictures; it can be "low", +"medium" or "high". Use "high" for no rescaling. The actual size of the +pictures for "low" and "medium" is hard-coded in the script (see "Limitations +and bugs" below). `` is the base directory in which the converted albums will be stored; each album will be in a separate sub-folder @@ -41,7 +46,7 @@ For example, this will convert every album under Limitations and bugs: -- Existing destination files will be **OVERWRITEN WITHOUT WARNING**! +- Existing destination files will be **OVERWRITTEN WITHOUT WARNING**! - Input files must have the extention `.tiff` (lowercase), not `.tif`. - The albums provided on the command-line must contain TIFF images directly; sub-folders won't be searched. @@ -49,8 +54,9 @@ Limitations and bugs: album will be generated as a subfolder of ``, even if the original albums are stored in different places. It is easy to modify this behaviour in the script if needed. -- To change the quality settings or the output format, you will have to edit - the script (see the `USER CONFIGURATION` section of the script). +- To change the output format or the size of the generated pictures (for "low" + and "medium" quality settings), you will have to edit the script (see the + "USER CONFIGURATION" section of the script). Dependencies: diff --git a/graphics/tiff-batch-convert.sh b/graphics/tiff-batch-convert.sh index 972753c..9701405 100755 --- a/graphics/tiff-batch-convert.sh +++ b/graphics/tiff-batch-convert.sh @@ -24,11 +24,6 @@ set -e # Format to convert the TIFF images to (lowercase) FORMAT="jpg" -# Resolution of the converted pictures: low, medium or high. -# Use "high" for no rescaling. The actual size of the pictures for "low" and -# "medium" depends on the next two options below. -QUALITY="medium" - # Maximum size of the pictures for the "low" quality setting. LOW_SCALE="800x800" @@ -39,6 +34,22 @@ MEDIUM_SCALE="2000x2000" # END OF USER CONFIGURATION # ############################# +# Do we have at least a quality setting, an input album and a destination +# folder? +if [ $# -lt 3 ] ; then + echo "Usage:" >&2 + echo " $0 [ALBUM2 [...]]" >&2 + echo ' can be "high" (no rescaling), "medium" or "low".' >&2 + echo ' is the base directory in which the converted albums will be stored.' >&2 + echo 'Each is a directory containing TIFF files.' >&2 + exit 1 +fi + +QUALITY="$1" +shift +ALBUM_DEST="$1" +shift + # Should the pictures be resized, depending on the quality setting? if [ "$QUALITY" = "low" ] ; then SCALE_OPT="-scale $LOW_SCALE" @@ -52,18 +63,6 @@ else exit 1 fi -# Do we have at least an input album and a destination folder? -if [ $# -lt 2 ] ; then - echo "Usage:" >&2 - echo " $0 [ALBUM2 [...]]" >&2 - echo "DESTINATION is the base directory in which the converted albums will be stored." >&2 - echo "Each ALBUM is a directory containing TIFF files." >&2 - exit 1 -fi - -ALBUM_DEST="$1" -shift - # Convert the pictures while [ $# -gt 0 ] ; do ALBUM="$1"