diff options
Diffstat (limited to 'scripts/.local/bin/compress-pdf')
| -rwxr-xr-x | scripts/.local/bin/compress-pdf | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/scripts/.local/bin/compress-pdf b/scripts/.local/bin/compress-pdf new file mode 100755 index 0000000..d1511d6 --- /dev/null +++ b/scripts/.local/bin/compress-pdf @@ -0,0 +1,30 @@ +#!/bin/sh + +# https://askubuntu.com/questions/113544/how-can-i-reduce-the-file-size-of-a-scanned-pdf-file +#-dPDFSETTINGS=/screen lower quality, smaller size. (72 dpi) +#-dPDFSETTINGS=/ebook for better quality, but slightly larger pdfs. (150 dpi) +#-dPDFSETTINGS=/prepress output similar to Acrobat Distiller "Prepress Optimized" setting (300 dpi) +#-dPDFSETTINGS=/printer selects output similar to the Acrobat Distiller "Print Optimized" setting (300 dpi) +#-dPDFSETTINGS=/default selects output intended to be useful across a wide variety of uses, possibly at the expense of a larger output file +PDFSETTINGS="/printer" +image_resolution="300" + +basename=$(echo "$1" | cut -f 1 -d '.') + +# full list of parameters +# https://ghostscript.com/docs/9.54.0/VectorDevices.htm + +#-dCompatibilityLevel=1.4 \ +gs -q -dNOPAUSE -dBATCH -dSAFER \ + -sDEVICE=pdfwrite \ + -dPDFSETTINGS="$PDFSETTINGS" \ + -dEmbedAllFonts=true \ + -dSubsetFonts=true \ + -dColorImageDownsampleType=/Bicubic \ + -dColorImageResolution="$image_resolution" \ + -dGrayImageDownsampleType=/Bicubic \ + -dGrayImageResolution="$image_resolution" \ + -dMonoImageDownsampleType=/Bicubic \ + -dMonoImageResolution="$image_resolution" \ + -sOutputFile="$basename.compressed.pdf" \ + "$1" |
