-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathbatch-scale
More file actions
executable file
·54 lines (47 loc) · 992 Bytes
/
Copy pathbatch-scale
File metadata and controls
executable file
·54 lines (47 loc) · 992 Bytes
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
#!/usr/bin/env bash
usage () {
echo "batch-scale [OPTION...] INPUTFILE OUTPUTFILE"
echo "Read the INPUTFILE image, scale it to fit in a square,"
echo "and write the result into OUTPUTFILE."
echo " Options:"
echo " -s PIXELS Size of the square's side, in pixels."
echo " e.g. 640, 800, 1024 (default: 800)"
echo " -h Show this help."
}
scale () {
gimp -ib '(batch-scale '"$1"' "'"$2"'" "'"$3"'") (gimp-quit 0)'
}
pixels=800
while getopts hs: opt
do
case "$opt" in
s)
pixels="$OPTARG"
;;
h)
usage
exit 0
;;
'?')
exit 1
;;
*)
echo "unhandled option {$opt}" 1>&2
exit 1
;;
esac
done
shift "`expr $OPTIND - 1`"
# There should be two arguments left: INPUTFILE OUTPUTFILE.
if [ "$#" -lt 2 ]
then
echo "missing argument" 1>&2
exit 1
elif [ "$#" -gt 2 ]
then
echo "too many arguments" 1>&2
exit 1
fi
input="$1"
output="$2"
scale "$pixels" "$input" "$output"