Page 1 of 1

How can I reduce pdf file sizes using imagemagick?

Posted: 2017-04-10T23:20:19-07:00
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.

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

Posted: 2017-04-10T23:42:37-07:00
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.

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

Posted: 2017-04-11T09:56:39-07:00
by brandoncc
Thank you for the feedback @fmw42. Do you happen to know of a better tool which I can achieve this with?

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

Posted: 2017-04-11T10:09:12-07:00
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.