Thursday, 7 May 2009

EPS to SVG

Wow it's been a while since I've update this!

I have several images that I got from Cisco that are in EPS format and I wanted to use them in Inkscape for diagrams, etc. They're public domain, so I wanted to see if I could give them back to the Open Clip Art Library once I was done.

I got them from the Cisco site but couldn't find anything that could easily convert them on the command line. The ways I found involved converting to PDF and importing in Inkscape. The best way was loading them in Scribus and exporting as SVG, which worked fine, but do that with 300+ files!

In the end I found that I could use pstoedit to convert to another format and then from that format to svg. This worked flawlessly and I didn't even encounter any problems on the final svg file like the website claimed there would be.

This is what I did:

for EPS in *.eps ; do FIG=`echo "$EPS" | sed -e s/eps$/fig/` ; SVG=`echo "$EPS" | sed -e s/eps$/svg/` ; echo "Converting ... $EPS" ; pstoedit "$EPS" -f fig "$FIG" ; fig2dev -L svg "$FIG" cisco_svg/"$SVG" ; rm -f "$FIG" ; done
It worked like a charm.

-P

(Note: I've fixed the script. Thanks to Nelnik pointing out in the comments that my sed for /eps/fig/ would convert steps.eps into stfig.eps. This is due to me not being specific enough. Adding the $ at the end of the /eps/ makes it look specifically for something ending in eps. This would match the extension only in steps.eps.)
Post a Comment