ImageMagick Command Line convert PNG to EPS with Transparency

Tom Pennetta picture Tom Pennetta · Apr 15, 2013 · Viewed 8k times · Source

I am trying to do a simple conversion from a transparent PNG file to EPS with transparency and currently my command looks like this:

convert "image1.png" "image1.eps"

It looks like all I am getting is a black image. Any ideas?

Thanks!

Answer

chiliNUT picture chiliNUT · Jan 11, 2015

Converting a PNG to an EPS is more than just a simple format conversion. Its changing from a raster image to a vector image, so the raster image has to be "traced". The popular command line tool for doing this is potrace. With potrace installed (and its component tool mkbitmap) you could do it with something like this:

convert image1.png image1.bmp
mkbitmap image1.bmp -o image1.pgm
potrace image1.pgm -e -o image1.eps

The call to mkbitmap converts the color image to a graymap more suitable for tracing. This will yield an eps with black lines on a white background. If you need a full color trace, inkskape is a GUI tool for doing this, and an inkscape user homebrewed a command line tool to do it, which can be found here