How to reduce the size of a pdf file from command line

compressionpdf

I know this question has been answered in other threads, but none of the solutions worked for me.
I have a pdf file which contains 4 plots with millions of colourful dots (Manhattan plots). The pdf file is so big (~100 MB) and I cannot t even open it properly on my computer.
I have tried gs and commands like

gs -sDEVICE=pdfwrite -dPDFSETTINGS=/ebook -q -o output.pdf manhattan_plots_long.pdf

but seems that it does not work and I get an error message which says
"Unable to convert color space to sRGB, reverting strategy to LeaveColorUnchanged."

I could find another code which fixes this error, but the new pdf file has the same size!

gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dNOPAUSE -dQUIET -dBATCH \
  -dAutoRotatePages=/None -dUseCIEColor -sOutputFile=output.pdf input.pdf

I do not understand what is wrong, is there any solution for my problem? thanks

Best Answer

Try adding -r150 to the second command, so

gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dNOPAUSE -dQUIET -dBATCH \ -dAutoRotatePages=/None -dUseCIEColor -r150 -sOutputFile=output.pdf input.pdf

You can play with numbers smaller than 150 to reduce image DPI.

Another option that can help is -dCompressFonts=true