I am compressing large PDF files (+10 MB in size) with GS using the following snippet:
gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/screen -dNOPAUSE -dQUIET -dBATCH -sOutputFile=shrink.pdf large_2.pdfThe problem is it took around 5 - 10 minutes to compress a 35MB file to 10 MB's.
Is this normal? I have an average machine, quad core - however I'm worried it'll be slow on the server as well. Is this fixed when I put it on a more powerful server?
The pdf I'm running compression on is National Aeronautics and Space Administration FY 2014 PRESIDENT’S BUDGET REQUEST SUMMARY (34 MB)
32 Answers
I compressed the same file on my main Ubuntu desktop (15.04) and it took 49.401 seconds to complete. The machine has an Intel i5-4690k Quad-Core clocked at 3.9 GHz and 12GBs of Memory clocked at 1600MHz. During the compression it never maxed out more than one core and only ever used two cores at any given time.
For comparison I also ran it on my Mini-ITX machine (Ubuntu Server 15.04) and it took 3 minutes and 16.050 seconds to compress the file. This machine has an Intel J1800 Dual-Core Processor clocked at 2.41GHz and 4GBs of Memory clocked at 1333MHz.
Below is the output I got from running the time command in front of the gs command:
Ubuntu Desktop
real 0m49.401s
user 0m49.084s
sys 0m0.208sMini-ITX Machine
real 3m16.050s
user 3m14.684s
sys 0m0.924sAll of this suggests that a more powerful processor definitely makes a difference to the compression time but given that only two cores were used on my desktop machine I'd say clock speed is much more important to the compression time than number of cores but without knowing the exactly model of processor it is hard verity this against your setup.
I used below commands but it didnt compress my pdf file substantially. Some times some of the portion was blackened after compression.
gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/ebook -dNOPAUSE -dQUIET -dBATCH -sOutputFile=output.pdf $INPUTFILE"ps2pdf -dPDFSETTINGS=/ebook %s %s" % (input_file_path, out_file_path)
After too much wandering over the web I just couldn't find the right compression library. I came across pdfcompressor.com. This is just awesome website. It compresses the pdf by 95% ( 15Mb of files). So I used selenium and Tor to automate the compression. Checkout my Github Repository.
[GITHUB] ()