Shrinkpdf: shrink PDF files with Ghostscript
The simplest shell script in the world to shrink your PDFs (as in reduce filesize) under Linux with Ghostscript. Inspired by some code I found in an OpenOffice Python script (I think). It feeds an existing PDF through Ghostscript, downsamples the images to 72dpi, and does some other stuff. Pretty straightforward.
shrinkpdf.sh
Download the script by clicking the filename at the top of the box. #!/bin/sh
gs -q -dNOPAUSE -dBATCH -dSAFER \
-sDEVICE=pdfwrite \
-dCompatibilityLevel=1.3 \
-dPDFSETTINGS=/screen \
-dEmbedAllFonts=true \
-dSubsetFonts=true \
-dColorImageDownsampleType=/Bicubic \
-dColorImageResolution=72 \
-dGrayImageDownsampleType=/Bicubic \
-dGrayImageResolution=72 \
-dMonoImageDownsampleType=/Bicubic \
-dMonoImageResolution=72 \
-sOutputFile=out.pdf \
$1
UsageIf it's not downloading just right click and 'save link as', make sure the file are in 'home' folder.
Then run:
sh shrinkpdf.sh yourfile.pdf
This produces a shrunken file named out.pdf
in the current directory.Sorry, Windows users; this one is Linux only. Ghostscript does run under Windows, but I don't know much about Windows scripting. You could try typing all these parameters on the commandline by hand.
You can increase the quality by changing the '72' number in the script to what ever number you want (ex: 120) for better image quality.
Good Luck.
Credit goes to http://www.alfredklomp.com/programming/shrinkpdf/
No comments:
Post a Comment