I need to automatically reduce the size of some user uploaded pdfs so that they can be sent via email.
I have a little imagemagick oneliner that reduces the size for me:
convert -density 120 -quality 10 -compress jpeg original.pdf output.pdf
basically exports every page of the pdf in jpg, updates density and quality and repacks the pages in a new PDF.
this works perfectly, except that with this command sometimes the files end up bigger, and I need to rerun tweaking density and quality to get the lowest size where the text in the pdf documents is still readable.
I'm not sure how to automate it. I thought to use identify to get characteristics of the files (height width density... ) and do stuff like half the figures or sth similar. but I'm struggling to get this info about the files.
Any suggestions?
Thanks,