-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathpdf-shrink.sh
More file actions
executable file
·40 lines (34 loc) · 883 Bytes
/
pdf-shrink.sh
File metadata and controls
executable file
·40 lines (34 loc) · 883 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
## options
## -i, --input <path>
## -o, --output <path>
# GENERATED_CODE: start
# No-arguments is not allowed
[ $# -eq 0 ] && sed -ne 's/^## \(.*\)/\1/p' $0 && exit 1
# Converting long-options into short ones
for arg in "$@"; do
shift
case "$arg" in
"--input") set -- "$@" "-i";;
"--output") set -- "$@" "-o";;
*) set -- "$@" "$arg"
esac
done
function print_illegal() {
echo Unexpected flag in command line \"$@\"
}
# Parsing flags and arguments
while getopts 'hi:o:' OPT; do
case $OPT in
h) sed -ne 's/^## \(.*\)/\1/p' $0
exit 1 ;;
i) _input=$OPTARG ;;
o) _output=$OPTARG ;;
\?) print_illegal $@ >&2;
echo "---"
sed -ne 's/^## \(.*\)/\1/p' $0
exit 1
;;
esac
done
# GENERATED_CODE: end
convert -compress jpeg -density 150x150 -quality 80 $_input.pdf "$_input"_x.pdf