-
Notifications
You must be signed in to change notification settings - Fork 14
/
shrinkpdf.sh
executable file
·41 lines (38 loc) · 923 Bytes
/
shrinkpdf.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
#!/bin/bash
#
# Shrink filesize of a PDF using GhostScript
#
# syntax :
# ./shrinkpdf.sh in=[input-file].pdf out=[output-file].pdf res=[resolution]
outfile="out.pdf"
res="72"
for arg; do
case $arg in
in=*) infile=${arg#in=};;
out=*) outfile=${arg#out=};;
res=*) res=${arg#res=};;
esac;
done
if [ -z "$infile" ]; then
usage;
exit 1;
fi
echo "Shrinking pdf..."
echo "This may take some time."
gs -q -dNOPAUSE -dBATCH -dSAFER \
-sDEVICE=pdfwrite \
-dCompatibilityLevel=1.5 \
-dPDFSETTINGS=/ebook \
-dEmbedAllFonts=true \
-dSubsetFonts=true \
-dColorImageDownsampleType=/Bicubic \
-dColorImageResolution=$res \
-dGrayImageDownsampleType=/Bicubic \
-dGrayImageResolution=$res \
-dMonoImageDownsampleType=/Bicubic \
-dMonoImageResolution=$res \
-sColorConversionStrategy=LeaveColorUnchanged \
-sOutputFile="$outfile" \
"$infile"
echo "Finished."
echo "Output data saved to $outfile"