How can I reduce pdf file sizes using imagemagick?

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
brandoncc
Posts: 2
Joined: 2017-04-10T23:13:04-07:00
Authentication code: 1151

How can I reduce pdf file sizes using imagemagick?

Post by brandoncc »

Hello,

I am trying to figure out how to simulate the "Reduce File Size" setting in Acrobat Pro. I work with a lot of PDF files with many images which are created using the prawn ruby gem. The last two were 164MB and 417MB. Exporting them in Acrobat using the Reduce File Size setting compressed them both down to 7.5MB. I have tried reading the pdf in and then writing it to a new file and that does make a smaller file, but the quality is extremely compromised. I have tried lots of different compression types and none have produced decent quality pdf files.

Thank you for any help you can offer.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: How can I reduce pdf file sizes using imagemagick?

Post by fmw42 »

Imagemagick will rasterize vector PDF files and thus make them much larger. If you have a raster image in a vector shell, then you should extract the image using pdfimages, process it to compress and then add the PDF shell onto it.

See http://www.imagemagick.org/Usage/formats/#vector

Imagemagick is not a good tool for optimizing PDF images.
brandoncc
Posts: 2
Joined: 2017-04-10T23:13:04-07:00
Authentication code: 1151

Re: How can I reduce pdf file sizes using imagemagick?

Post by brandoncc »

Thank you for the feedback @fmw42. Do you happen to know of a better tool which I can achieve this with?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: How can I reduce pdf file sizes using imagemagick?

Post by fmw42 »

I do not know of any tools specific to your task. But you can extract the image from the pdf using pdfimages. Then compress it. Then put it back into a PDF shell by converting to PDF.
Post Reply