# How to extract flattened path data from SVG file

**URL:** <https://discourse.julialang.org/t/how-to-extract-flattened-path-data-from-svg-file/57027>\
**Category:** General Usage\
**Created:** [March 12, 2021, 3:01pm UTC](https://discourse.julialang.org/t/how-to-extract-flattened-path-data-from-svg-file/57027 "2021-03-12T15:01:30Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![arnief3](https://avatars.discourse-cdn.com/v4/letter/a/a698b9/32.png) [@arnief3](https://discourse.julialang.org/u/arnief3)\
**Post date:** [March 12, 2021, 3:01pm UTC](https://discourse.julialang.org/t/how-to-extract-flattened-path-data-from-svg-file/57027/1 "2021-03-12T15:01:30Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![cormullion](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cormullion/32/49131_2.png) [@cormullion](https://discourse.julialang.org/u/cormullion)\
**Post date:** [March 12, 2021, 4:24pm UTC](https://discourse.julialang.org/t/how-to-extract-flattened-path-data-from-svg-file/57027/2 "2021-03-12T16:24:11Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![arnief3](https://avatars.discourse-cdn.com/v4/letter/a/a698b9/32.png) [@arnief3](https://discourse.julialang.org/u/arnief3)\
**Post date:** [March 12, 2021, 4:53pm UTC](https://discourse.julialang.org/t/how-to-extract-flattened-path-data-from-svg-file/57027/3 "2021-03-12T16:53:49Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![cormullion](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cormullion/32/49131_2.png) [@cormullion](https://discourse.julialang.org/u/cormullion)\
**Post date:** [March 12, 2021, 5:19pm UTC](https://discourse.julialang.org/t/how-to-extract-flattened-path-data-from-svg-file/57027/4 "2021-03-12T17:19:48Z")

</div>

Thanks! Plenty more awesome packages to go! 😂

---

<div class="post-metadata">

**Author:** ![lobingera](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lobingera/32/211_2.png) [@lobingera](https://discourse.julialang.org/u/lobingera)\
**Post date:** [March 13, 2021, 9:09am UTC](https://discourse.julialang.org/t/how-to-extract-flattened-path-data-from-svg-file/57027/5 "2021-03-13T09:09:58Z")

</div>

I just checked [https://developer.gnome.org/rsvg/2.50/](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.

---

<div class="post-metadata">

**Author:** ![lobingera](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lobingera/32/211_2.png) [@lobingera](https://discourse.julialang.org/u/lobingera)\
**Post date:** [March 13, 2021, 9:11am UTC](https://discourse.julialang.org/t/how-to-extract-flattened-path-data-from-svg-file/57027/6 "2021-03-13T09:11:11Z")

</div>

[http://lib2geom.sourceforge.net/](http://lib2geom.sourceforge.net/) is used in inkscape.
