I\'m converting an image from .png to .eps and it hugely increases the file size. Can anyone explain why this is, and how to prevent it increasing so much.
I\'m usin
Converting a PNG file (designed for bitmap data) into an EPS (designed for vector data) is always going to result in a larger file size, as the EPS is effectively just wrapping an EPS data structure around the original image data (which it most likely won't store in anywhere near as effective a manner as a PNG file).
The correct solution is to store bitmaps as PNGs and vector graphics as EPS or SVG, etc. (i.e.: Use the appropriate file format for the content in question rather than attempting to impose a meaningless "one size fits all" approach.)
Use level 3 postscript if you can. In general, level 3 will produce the smallest files. Level 2 provides the best compatibility, and works well with jpeg images. (see http://electron.mit.edu/~gsteele/pdf/)
convert fig.png eps3:fig.eps
I had a similar problem and solved it using the -sample parameter:
convert image.png -sample 100 image.eps
and tweak the -sample
value to fit your need.
Also see ImageMagick v6 Examples -- Resize or Scaling
N.B. The inverse (from EPS/PDF to PNG/JPG) can be tuned using -density.
convert
indeed blows up the file size because it stores the graphics data uncompressed. A better compression and smaller file size can be achieved by e.g. manually converting using gimp
, or by doing
convert image.png image.pdf
pdftops -eps image.pdf
In my case, for example, this results in an eps file with a size of 0.3 MB instead of 5.2 MB (when using convert file.png file.eps
directly).
It is possible that the problem is that the convert
application you use just does not support embedding PNG into EPS. When using properly configured Adobe Acrobat Professional I newer got unexpectedly huge increase of the file size. But you should properly configure first your "PNG to PDF" conversion settings. Then you should export (or Save As) generated PDF as EPS from Acrobat.