Tuesday, December 15, 2009

Batch convert PNG to EPS

I like to produce documents in LaTeX, but I like to get the output in PDF. Luckily there is pdflatex which does this quite nicely. Unfortunately latex (using eps images) and pdflatex (using many other formats) cannot use the same image files. Therefore as I am trying to publish a paper in a journal, and they want eps images, I need to convert all my png to eps.

In trying to find a converter that does this nicely, I have found many things that don't do it exactly right. However I found a script by Thomas Henlich that will use several converters and creates great output. You can get it from his site here.

To do all the rest of the dirty work of converting everything in one directory in png format to another in eps I created this script. You need to have perl to run the script. You need Henlich's script (in your $PATH) and you need its dependancies. Be sure that it is executable and follow its directions. Hopefully it helps.


Hakan Serçe said...

You can also use the following bash command to do the job. You can put it into a bash script for easier usage:

for file in *.png; do file2=${file%.png};png2eps $file2.png > $file2.eps; done;

Alireza Haghdoost said...

I buy the short script in the comment section !