10
$\begingroup$

So I have 2D plot, made with DensityListPlot. Mathematica just cannot export them properly to PDF, so what I want to do is 1) export the plot itself, without axes, labels, etc, as a jpg image, and 2) Inset this image in an empty graphics containing only axes, labels etc. So far so good.

The problem is that when I export the final graphics to PDF, the image are not compressed at all -- and the file end up weighing 400k instead of 30k.

The question is: how do I specify the format and compression factor of images embedded in a pdf?

$\endgroup$
7
  • $\begingroup$ Rasterize the image first maybe? $\endgroup$
    – fizzics
    Oct 10, 2012 at 10:07
  • 4
    $\begingroup$ Thanks Chris. I used gs instead of cutepdf to optimise the PDF, and it works very well. Still Wolfram really need to improve PDF export of 2D graphics... $\endgroup$
    – Mammouth
    Oct 10, 2012 at 10:59
  • 1
    $\begingroup$ Have you taken a look at [mathematica.stackexchange.com/questions/3190/…, [mathematica.stackexchange.com/questions/1542/…, [mathematica.stackexchange.com/questions/3926/…? My guess is that the size of the file is dictated by the JPEG. Have you tried compressing the JPEG that you export? $\endgroup$
    – tkott
    Oct 10, 2012 at 14:01
  • 1
    $\begingroup$ @Mammouth I'm not quite sure why you believe the raster images aren't compressed, but they most certainly are. If you look in the file you can clearly see the /FlateDecode filter applied to the image stream. This is a lossless compression method so it does not achieve as high a compression ratio as a lossy method (like JPEG). $\endgroup$
    – ragfield
    Oct 10, 2012 at 14:45
  • 1
    $\begingroup$ @ragfield: fair enough. But how do I tell Mathematica to use jpeg ? $\endgroup$
    – Mammouth
    Oct 11, 2012 at 19:21

1 Answer 1

5
$\begingroup$

Try using EPS as export format (e.g. Export["filename.eps", img], then converting the resulting file to PDF with epstopdf or ps2pdf. This produces much better results than Mathematica's PDF export in most cases.

$\endgroup$
1
  • $\begingroup$ Doesn't solve all problems. $\endgroup$ Feb 5, 2013 at 0:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.