Showing posts with label pdf compress. Show all posts
Showing posts with label pdf compress. Show all posts

Monday, April 18, 2011

Compress Scanned PDF document using ImageMagick

Today, I needed to scan a document and emailed it to a friend. The scanned document was over 20M for a page and I had several pages to be sent. Apparently, the scanned document was too large and  I needed to compress them.

One way to do that in Mac is using Preview. Open the scanned pdf with Preview, choose "File/Save As" and then "Reduce File Size" in the "Quartz Filter" drop down list.  However, the image result I got from this method was very poor. The characters in the image were almost unreadable.

I tied several other ways by googling the topic, most of the methods I found did not allow me to set compression ratio, Finally, I found ImageMagic which allowed me to set compression ratio explicitly.  Here is the command I used to compress the scanned PDF file.

convert -density 300x300 -quality 5 -compress  jpeg input.pdf output.pdf


The quality parameter is used to  set compression ratio and it should be between 1 to 99 with 1 being the lowest quality and highest compression ratio setting.