3

Is there an easy way to convert a batch of EPS files to SVG format, using ImageMagick or something else?

I have thousands of vector files in EPS format and I need to convert them to SVG.

3
  • 2
    ImageMagick isn't really meant for converting vector formats, it's possible but it will convert to an intermediary raster image which isn't good (see imagemagick.org/Usage/formats/#vector)
    – Cai
    Dec 12, 2016 at 1:11
  • Agreed. The sort of obvious answer is the use a Photoshop action to accomplish this task.
    – ErickP
    Dec 12, 2016 at 1:14
  • 3
    Converting from EPS to SVG format may give you what you need
    – Cai
    Dec 12, 2016 at 1:15

3 Answers 3

3

As has been said by others, ImageMagick isn't really for vector-to-vector conversion.

I don't have much experience using Inkscape with .eps files, so I don't know reliable it is for ones that weren't generated by the barcode command, but, at least in theory, you can do this using its command-line interface.

(It used to have a bug in its EPS parser which would mess up the colors, but that was apparently fixed in 2015.)

Given that you're interested in using ImageMagick, I'm guessing you have access to a POSIX-compliant shell, so here's how you'd do it in shell script:

#!/bin/sh

for file in *.eps; do
    inkscape -f "$file" --export-plain-svg="${file%.*}.svg"
done

Some other options which I haven't used myself, but which others swear by include:

  • Uniconverter
  • ps2pdf -dEPSCrop (from Ghostscript) followed by pdf2svg
3
  • Files generated by ps2pdf -dEPSCrop myFile.eps followed by pdf2svg myFile.pdf myFile.svg seem to be a bit larger than the ones generated by Inkscape. Like 788k vs 430k. Feb 15, 2020 at 17:39
  • Given that Inkscape presents a dialog with a bunch of different tunables when loading an EPS file interactively, I could see that happening on the input side (interpreting EPS) or the output side (writing SVG) or both. Since pdf2svg is a frontend for Poppler, how does the Inkscape GUI's "Import via Poppler" checkbox change things? Also, how do they compare if your run both through an SVG minifier like svgcleaner, svgo, or scour?
    – ssokolow
    Feb 16, 2020 at 3:20
  • Looks like it's a bit of both. With the EPS I tried it on, pdf2svg made a 35K SVG while Inkscape made a 13K one. (and Inkscape via Poppler did 43K) SVGO dropped the pdf2svg output to 4.1K while leaving Inkscape unchanged, but it reset the font on both. SVG Cleaner got Inkscape down to 4.1K and didn't make visible changes to either, but it only got pdf2svg's output down to 20K. I'd need to hack together some custom comparison scripting to identify exactly which SVGO option is responsible and what file size SVGO can achieve from pdf2svg with it disabled but everything otherwise at defaults.
    – ssokolow
    Feb 16, 2020 at 4:05
1

Scribus is an Open Source software. Use File/Open... to open the EPS file and then File/Export/As SVG... to save the result as an SVG file. Unlike ImageMagick, it will keep the vector format.

Scribus has scripting capabilities and if I get this page right, the function name for exporting is ImageExport() but there's no example on how to use it.

Update: in Scribus 1.4.6, there's no export functionality for SVG via ImageExport(). I did

svg = scribus.ImageExport()
print(svg.allTypes)

which only gives me the types 'bmp', 'ico', 'jpeg', 'jpg', 'png', 'ppm', 'tif', 'tiff', 'xbm' and 'xpm'.

Scribus 1.5.3 adds 'cur', 'dds', 'icns', 'pbm', 'pgm', 'wbmp and 'webp', but still has no SVG export.

I have opened a feature request.

1
  • This just worked well for me. Other methods did not preserve the vector nature of the image.
    – pauljohn32
    May 21, 2020 at 21:47
0

Since I've faced this issue many times, I've ended with a service based solution. Normally I use the service from https://cloudconvert.com/ but recently I noticed they also offers a cli which can be invoked to convert any kind of file that one can see on their site.

Just register, obtain a free (just be sure of the free limitations) API Key, install their cli as described here and then (optional) create this simple script for a drag&drop conversion:

'echo off
set CLOUDCONVERT_API_KEY=[your_api_key]
cloudconvert -f svg %*

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy