eps to something

I generated an HTML version of a product catalogue and found that the result was very bad due to poor PNG images. To get good PNG images, I had to write some code. Here it is: convertor from eps to other formats.

Using the standard ways

The first and obvious attempt to convert images was:

$ convert file.eps file.png

The result was bad.

I noticed that "epstopdf" generated good pdf and tried to convert from the pdf files, not from the eps files. The result was the same.

Then I thought that "convert" uses "gs", and decided to play with "gs".

gs -dBATCH -sDEVICE=png16m -sOutputFile=file.png file.eps

The result was the same.

Finally, I investigated the internals of "epstopdf". I found that it uses "gs", but it gives data to "gs" through a pipe, and calculates the bounding box and crops the resulted image on its own. As the PDF result is good, I decided to use the same way for other formats. I've added some code "epstopdf" and renamed it to "epstosmth".

"epstosmth": eps to something

Based on "epstopdf" by Sebastian Rahtz and Heiko Oberdiek. New parameters are added:

  --gsdev=:    select gs device
  --gsopt=:   additional gs options

To get list of gs devices and options, run "gs --help".

Examples:

eps to png:

$ epstosmth --gsdev=png16m file.eps

eps to jpeg, resolution 85 dpi:

$ epstosmth --gsdev=jpeg --gsopt=-r85x85 file.eps

Error: /undefined in II*

Converting some EPS files gives the error reproduced in the title.

After some researh, I found that these files contains a TIFF preview in some DOS dialect of EPS. Manual fix is possible:

* delete binary header,
* delete binary TIFF data at the end of EPS.

For automatic fixing I found epstool tool. It can extract PostScript from DOS EPS files. I haven't tested the tool yet.

Categories:

Updated: