Effective conversion from raster to EPS

There are several ways to use raster images (JPEG, PNG, TIFF) in LaTeX. Fortunately, PDFLaTeX supports JPEG and PNG directly. However, sometimes one has to use only EPS (PostScript) images. This post tells how to “vectorize” the raster effectively.

Out of the several conversion tools (ImageMagick, GIMP), the most effective, IMO, is sam2p. It produces the smallest EPS possible. sam2p is available in Debian repositories.

sam2p is a command line tool. To convert a PNG file image.png to EPS file image.eps do:

$ sam2p image.png EPS: image.eps

I have tried converting some Google Earth screenshots (they are fairly complicated images with a lot of details). These are the sizes of original PNG and of converted EPS images (with ImageMagick's convert and with sam2p):

$ ls -rSsk1 google-earth-screenshot*
1756 google-earth-screenshot.png
3016 google-earth-screenshot-(sam2p).eps
4304 google-earth-screenshot-(convert).eps
Certainly, sam2p-produced EPS is larger than PNG, but it is much smaller than convert-produced EPS. On some images the difference may be even bigger.

BTW, EPS produced by sam2p is EPSF-3.0, and should be compatible with the most of vector graphics software. It seems like often using sam2p may be a better option than using built-in import raster tool. At least when the size of the file matters.

Another tool for effective conversion from raster to EPS is bmeps, but I have not tried it.

P.S. I wrote this post also in Russian: Эффективная конвертация растра в EPS или PDF.