How to extract flattened path data from SVG file

I have used the python library svgpathtools to accomplish this task in the past. Can anyone recommend a way to accomplish this in Julia or am I better off using svgpathtools via PyCall?

I have been looking into Cairo.jl and Rsvg.jl (and Luxor.jl) but I can’t figure out how to extract the path data from the imported svg.

I believe that the full Rsvg library lets you extract path information from the Rsvg handle/object, but this functionality hasn’t been added to Rsvg.jl as far as I can see, so there’s some work to do there for someone who can write code that interfaces with external libraries.

1 Like

Thank you for the feedback.

I have just started experimenting with PyCall.jl and svgpathtools and have been pleasantly surprised how smoothly the PyCall / Conda.jl testing is going. Think this may be my path forward.

By the way - I love Luxor.jl. It has been one of the highlights of my Julia journey so far!

2 Likes

Thanks! Plenty more awesome packages to go! :joy:

I just checked https://developer.gnome.org/rsvg/2.50/ , there are some functions to get elements of the SVG, but no direct access to paths. Both librsvg and libcairo are build for rendering, but not access to path elements in detail (like outline of stroke path), so svgpathtools is the best option to deal with path descriptions.

For libcairo exists some non-public APIs to read internal data. And with recording surfaces and cairo script one can access path construction.

http://lib2geom.sourceforge.net/ is used in inkscape.

1 Like