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.

8 comments:

  1. Thanks, this was very useful for me.

    ReplyDelete
  2. This works as advertised on the tin.

    ReplyDelete
  3. This comment has been removed by the author.

    ReplyDelete
  4. Yes, my friend, you are absolutely right. I want you to try this JPG to PDF converter. Not only this JPG to PDF converter is user friendly but also offers amazing results

    ReplyDelete
  5. Thank you man. This really helpful to me :)

    ReplyDelete
  6. If you want you can even try
    __EasyPDFGenerator__, it's free to use and you can compress merge or split pdf online :)

    ReplyDelete