-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathpresentation.sh
executable file
·64 lines (53 loc) · 1.95 KB
/
presentation.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/bin/bash
#
# Generates presentational copies for scanned pages.
# Intended to be called from quack.sh to generate images to shown on the QA page.
#
# Override settings by creating "presentation.settings" and specifying DEFAULT_COMMANDS
# and/or get_commands
#
SETTINGS="presentation.settings"
# geometry resizes to 50% (the > is redundant with percents <= 100, but we keep it
# as it is a fine default as we never want to enlarge).
# unsharp is for a high quality 300 DPI scan with no previous sharpen applied.
# level is highly source-specific. The default is a conservative starker contrast.
# no intensities > 240.
# Quality is for JPEG output. This needs to be quite high as JPEG artifacts are
# very visible with tiny text.
DEFAULT_COMMANDS="-geometry 50%x> -unsharp 0.8x0.1+0.8+2.0 -level 10,1.0,245 -quality 95"
# Input: source
# Output: COMMANDS (GraphicsMagick options)
function get_commands() {
local SOURCE="$1"
if [ "." != ".`echo \"$SOURCE\" | grep -o inesta`" ]; then
# This provider has very dark scans with no intensities > 240
COMMANDS="-geometry 50%x> -unsharp 0.8x0.1+0.8+2.0 -level 0,1.0,220 -quality 95"
return
fi
if [ "." != ".`echo \"$SOURCE\" | grep -o pex`" ]; then
# This provider has scans practically without any blown high- or low-lights
# Input is 400 DPI so we need to scale a bit more to reach ~150DPI
COMMANDS="-geometry 38%x> -unsharp 0.8x0.1+0.8+2.0 -level 30,0.8,240 -quality 95"
return
fi
COMMANDS="$DEFAULT_COMMANDS"
}
pushd `dirname $0` > /dev/null
ROOT=`pwd`
if [ -e "$SETTINGS" ]; then
echo "Sourcing settings from $SETTINGS"
source "$SETTINGS"
fi
popd > /dev/null
SOURCE="$1"
DESTINATION="$2"
if [ ! -f "$SOURCE" ]; then
echo "The image '$SOURCE' does not exist"
exit 2
fi
if [ "." == ".$DESTINATION" ]; then
echo "Usage: ./presentation.sh source destination"
exit 2
fi
get_commands "$SOURCE"
gm convert "$SOURCE" $COMMANDS "$DESTINATION"