Reputation: 176
I am trying to compress PDFs using Ghostscript. I have a folder of around 5000 PDF files, all of varying sizes (5-1000 pages) and appearances. The gs
command that I use successfully compresses 2700 of them. However, the remaining 2300, remain uncompressed and in many, cases have increased in size after applying the command. Below is my command which I call through a python script. Please tell me what I should add or remove to ensure that all PDF's are compressed.
gs \
-q \
-dNOPAUSE \
-dBATCH \
-dSAFER \
-sDEVICE=pdfwrite \
-dCompatibilityLevel=1.4 \
-dSubsetFonts=true \
-dUseFlateCompression=true \
-dOptimize=true \
-dProcessColorModel=/DeviceRGB \
-dDownsampleGrayImages=true \
-dGrayImageDownsampleType=/Bicubic \
-dGrayImageResolution=150 \
-dAutoFilterGrayImages=false \
-dDownsampleMonoImages=true \
-dMonoImageDownsampleType=/Bicubic \
-dCompressPages=true \
-dMonoImageResolution=150 \
-dDownsampleColorImages=true \
-dColorImageDownsampleType=/Bicubic \
-dColorImageResolution=150 \
-dAutoFilterColorImages=false \
-dPDFSETTINGS= /screen \
-sOutputFile = output.pdf
input.pdf
Upvotes: 2
Views: 3226
Reputation: 1215
Generally PDF compression is a difficult problem. Some documents can be very bloated and capable of being reduced greatly in size. Other documents are very well compressed already. Some documents aren't necessarily bloated and are already a good size based on their content.
Not all PDF software is created equally, some can work great for particular types of PDFs and others not so much. Unfortunately there's not a one size fits all answer for why a PDF can't be reduced in size further.
Upvotes: 1