Browse Source

tiff-batch-convert: quality is now an argument

master
Matteo Cypriani 1 year ago
parent
commit
b8619f8d0b
2 changed files with 26 additions and 21 deletions
  1. 10
    4
      graphics/README.md
  2. 16
    17
      graphics/tiff-batch-convert.sh

+ 10
- 4
graphics/README.md View File

@@ -28,7 +28,12 @@ smartphone.
28 28
 
29 29
 Usage:
30 30
 
31
-    tiff-batch-convert.sh <DESTINATION> <ALBUM1> [ALBUM2 [...]]
31
+    tiff-batch-convert.sh <QUALITY> <DESTINATION> <ALBUM1> [ALBUM2 [...]]
32
+
33
+<QUALITY> impacts the resolution of the converted pictures; it can be "low",
34
+"medium" or "high". Use "high" for no rescaling. The actual size of the
35
+pictures for "low" and "medium" is hard-coded in the script (see "Limitations
36
+and bugs" below).
32 37
 
33 38
 `<DESTINATION>` is the base directory in which the converted albums will be
34 39
 stored; each album will be in a separate sub-folder
@@ -41,7 +46,7 @@ For example, this will convert every album under
41 46
 
42 47
 Limitations and bugs:
43 48
 
44
-- Existing destination files will be **OVERWRITEN WITHOUT WARNING**!
49
+- Existing destination files will be **OVERWRITTEN WITHOUT WARNING**!
45 50
 - Input files must have the extention `.tiff` (lowercase), not `.tif`.
46 51
 - The albums provided on the command-line must contain TIFF images directly;
47 52
   sub-folders won't be searched.
@@ -49,8 +54,9 @@ Limitations and bugs:
49 54
   album will be generated as a subfolder of `<DESTINATION>`, even if the
50 55
   original albums are stored in different places. It is easy to modify this
51 56
   behaviour in the script if needed.
52
-- To change the quality settings or the output format, you will have to edit
53
-  the script (see the `USER CONFIGURATION` section of the script).
57
+- To change the output format or the size of the generated pictures (for "low"
58
+  and "medium" quality settings), you will have to edit the script (see the
59
+  "USER CONFIGURATION" section of the script).
54 60
 
55 61
 Dependencies:
56 62
 

+ 16
- 17
graphics/tiff-batch-convert.sh View File

@@ -24,11 +24,6 @@ set -e
24 24
 # Format to convert the TIFF images to (lowercase)
25 25
 FORMAT="jpg"
26 26
 
27
-# Resolution of the converted pictures: low, medium or high.
28
-# Use "high" for no rescaling. The actual size of the pictures for "low" and
29
-# "medium" depends on the next two options below.
30
-QUALITY="medium"
31
-
32 27
 # Maximum size of the pictures for the "low" quality setting.
33 28
 LOW_SCALE="800x800"
34 29
 
@@ -39,6 +34,22 @@ MEDIUM_SCALE="2000x2000"
39 34
 # END OF USER CONFIGURATION #
40 35
 #############################
41 36
 
37
+# Do we have at least a quality setting, an input album and a destination
38
+# folder?
39
+if [ $# -lt 3 ] ; then
40
+	echo "Usage:" >&2
41
+	echo "	$0 <QUALITY> <DESTINATION> <ALBUM1> [ALBUM2 [...]]" >&2
42
+	echo '<QUALITY> can be "high" (no rescaling), "medium" or "low".' >&2
43
+	echo '<DESTINATION> is the base directory in which the converted albums will be stored.' >&2
44
+	echo 'Each <ALBUM> is a directory containing TIFF files.' >&2
45
+	exit 1
46
+fi
47
+
48
+QUALITY="$1"
49
+shift
50
+ALBUM_DEST="$1"
51
+shift
52
+
42 53
 # Should the pictures be resized, depending on the quality setting?
43 54
 if [ "$QUALITY" = "low" ] ; then
44 55
 	SCALE_OPT="-scale $LOW_SCALE"
@@ -52,18 +63,6 @@ else
52 63
 	exit 1
53 64
 fi
54 65
 
55
-# Do we have at least an input album and a destination folder?
56
-if [ $# -lt 2 ] ; then
57
-	echo "Usage:" >&2
58
-	echo "	$0 <DESTINATION> <ALBUM1> [ALBUM2 [...]]" >&2
59
-	echo "DESTINATION is the base directory in which the converted albums will be stored." >&2
60
-	echo "Each ALBUM is a directory containing TIFF files." >&2
61
-	exit 1
62
-fi
63
-
64
-ALBUM_DEST="$1"
65
-shift
66
-
67 66
 # Convert the pictures
68 67
 while [ $# -gt 0 ] ; do
69 68
 	ALBUM="$1"

Loading…
Cancel
Save