File tree Expand file tree Collapse file tree 1 file changed +33
-0
lines changed
Expand file tree Collapse file tree 1 file changed +33
-0
lines changed Original file line number Diff line number Diff line change @@ -137,6 +137,39 @@ export do='--dry-run=client -o yaml'
137137export now='--force --grace-period=0'
138138
139139
140+ # ------------------------------------------------------------------------------
141+ # | PDF Utilities |
142+ # ------------------------------------------------------------------------------
143+
144+ compresspdf() {
145+ if [ $# -lt 2 ]; then
146+ echo "Usage: compresspdf INPUT.pdf OUTPUT.pdf [dpi]"
147+ echo "Default dpi = 200 (good for scanned docs / visa uploads)"
148+ return 1
149+ fi
150+
151+ local input="$1"
152+ local output="$2"
153+ local dpi="${3:-200}" # third arg optional, default 200
154+
155+ command gs \
156+ -sDEVICE=pdfwrite \
157+ -dNOPAUSE -dQUIET -dBATCH \
158+ -dCompatibilityLevel=1.6 \
159+ -dDetectDuplicateImages=true \
160+ -dDownsampleColorImages=true \
161+ -dColorImageDownsampleType=/Average \
162+ -dColorImageResolution="$dpi" \
163+ -dDownsampleGrayImages=true \
164+ -dGrayImageDownsampleType=/Average \
165+ -dGrayImageResolution="$dpi" \
166+ -dDownsampleMonoImages=true \
167+ -dMonoImageDownsampleType=/Average \
168+ -dMonoImageResolution=300 \
169+ -sOutputFile="$output" \
170+ "$input"
171+ }
172+
140173# ------------------------------------------------------------------------------
141174# | Other |
142175# ------------------------------------------------------------------------------
You can’t perform that action at this time.
0 commit comments