9

I have an SVG file coming from Inkscape, Illustrator, or any other application. I want to convert the shapes to lineto, moveto, curveto format.

What I want is something like:

./Appname svgfile outfilewithpath

I will give the SVG file as an argument, then my application will convert the object into the respective paths.

Paul Sweatte
  • 24,148
  • 7
  • 127
  • 265
skanzariya
  • 397
  • 1
  • 4
  • 10
  • Just to be clear, you want to convert elements such as `rect`, `circle`, `ellipse` and `polygon` into paths? – methodofaction Mar 04 '13 at 15:41
  • I come to know about Inkscape and found that it can do the Job, but what I want is I have ready made svg from any software and wanted to convert object into path. i.e. Move to Line To. Qt, Perl, Python, C, C++ any solution are accepted. – skanzariya Mar 14 '13 at 17:55

2 Answers2

6

Inkscape has a command-line interface. Use the Inkscape man page along with the verb source for reference:

The ObjectToPath verb converts an object to a path:

inkscape filename.svg --select=myobject --verb=ObjectToPath --export-plain-svg=filename_to_path.svg

The export-text-to-path argument converts text nodes to paths:

inkscape filename.svg --export-eps=filename.eps --export-text-to-path

These are related questions on how to run InkScape from Perl, Ruby, PHP or Python:

Community
  • 1
  • 1
Paul Sweatte
  • 24,148
  • 7
  • 127
  • 265
  • Inkscape itself can do the stuff and I am also very well aware about inkscape command line. I am looking for some other solution, perhaps Python or perl. for ex. Python/PerlApp svgfile outfilewithcoordinate.txt. I know svg is xml file and can be parsed with xml library. – skanzariya Mar 29 '13 at 16:38
4

This is what finally worked for me:

inkscape -f filename.svg --verb EditSelectAll --verb SelectionUnGroup --verb EditSelectAll --verb ObjectToPath --verb FileSave --verb FileQuit

It takes about 9 seconds to run and briefly opens the inkscape gui, which becomes the active application, so it's not ideal, but it's the only answer I could find that actually works.

les_h
  • 347
  • 1
  • 8