PNG to eps conversion massive increase in file size
Asked Answered
C

5

29

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 using Unix convert: convert image.png image.eps

Thanks for any help

Culley answered 10/12, 2010 at 12:28 Comment(0)
T
8

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.)

Tamtam answered 10/12, 2010 at 12:33 Comment(2)
For future reference I used "convert -density 300 myfig.png myfig.pdf" (the 300 is for a better quality), and then I used "pdftops -eps myfig.pdf". This process allowed me to create *.eps figures of size less than 0.5MB (before around 3-4MB ) and with a moderate quality. A little better that with the direct convert alone process. Maybe it's possible to improve the quality by increasing the density.Budget
The solution mentioned by @AnaS.H. is what worked best for me, out of all those in this post. You should turn your comment into an answer Ana!Berna
F
55

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
Flatware answered 11/11, 2013 at 11:23 Comment(5)
When using Miktex with texify (but not pdf mode) you can include the resulting eps file using includegraphics.Singly
I got this error: convert: unable to zip-compress image fig.eps @ error/compress.c/ZLIBEncodeImage/1280.Heyman
@warship: i got the same error, but it worked when i ran eps2Hageman
@Heyman Did you manage to fix this error? I'm getting it tooBeforehand
Finally the working answer! This works in Mac OS X too with brew! This is the only answer that provides smallest size with decent resolution from all of the above.Polysepalous
A
13

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).

Antrorse answered 23/4, 2012 at 13:13 Comment(3)
This did not work for me. The image went from 659Kb (PNG) to 750Kb (PDF) to 16.4Mb (EPS) even larger than using the direct convert *.png to *.eps which resulted in 12.8Mb.Berna
Gimp worked fine for me. However, if you have a lot of files, Gimp will not be as easy as a command-line solution.Mountford
gimp is the only thing that preserved the details in my images perfectly.Musicianship
T
8

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.)

Tamtam answered 10/12, 2010 at 12:33 Comment(2)
For future reference I used "convert -density 300 myfig.png myfig.pdf" (the 300 is for a better quality), and then I used "pdftops -eps myfig.pdf". This process allowed me to create *.eps figures of size less than 0.5MB (before around 3-4MB ) and with a moderate quality. A little better that with the direct convert alone process. Maybe it's possible to improve the quality by increasing the density.Budget
The solution mentioned by @AnaS.H. is what worked best for me, out of all those in this post. You should turn your comment into an answer Ana!Berna
D
2

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.

Drove answered 11/12, 2012 at 12:54 Comment(2)
This works in reducing the size but the quality is so bad it's almost useless. To obtain a higher quality you're forced to increase the sample parameter and the .eps image ends up having the same large size as it would with the direct conversion.Berna
Perfect! Worked like a charm.Abundance
S
1

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.

Sawyer answered 24/3, 2011 at 10:47 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.