I recently found out that it is surprisingly hard to convert an SVG file that consists of series of line segments into a list of those line segments in Python. I tried with ChatGPT and Claude but both were not able to find a solution that respects the entire specification, especially transforms. Initially, my expectation was that there must be a library for this kind of thing, but alas.
An SVG is all you need
41–50 of 155 posts
Re: An SVG is all you need
#42Re: An SVG is all you need
#43But can it read email? https://www.laws-of-software.com/laws/zawinski/
Re: An SVG is all you need
#44I recently found out that it is surprisingly hard to convert an SVG file that consists of series of line segments into a list of those line segments in Python. I tried with ChatGPT and Claude but both were not able to find a solution that respects the entire specification, especially transforms. Initially, my expectation was that there must be a library for this kind of thing, but alas.
Can't you do it by hand pretty easily? It's a list of coordinates separated by spaces. For example: "100,100 100,200 200,200 200,100"
Re: An SVG is all you need
#45I recently found out that it is surprisingly hard to convert an SVG file that consists of series of line segments into a list of those line segments in Python. I tried with ChatGPT and Claude but both were not able to find a solution that respects the entire specification, especially transforms. Initially, my expectation was that there must be a library for this kind of thing, but alas.
But there seems to be a lot of SVG specific tooling and code to do this in python?
Re: An SVG is all you need
#46My day job involves building dashboards, and SVGs have been invaluable for crisp icons and graphs... the portability across sizes is a blessing, but some of the more exotic filter effects still fail in certain browsers. ALSO I've run into security reviews that flag inline SVGs because they can embed scripts... would love to see more tooling to lint and sanitize them before deployment. BUT seeing a two-decade-old vect…
Did you see?:
Re: An SVG is all you need
#47I recently found out that it is surprisingly hard to convert an SVG file that consists of series of line segments into a list of those line segments in Python. I tried with ChatGPT and Claude but both were not able to find a solution that respects the entire specification, especially transforms. Initially, my expectation was that there must be a library for this kind of thing, but alas.
https://pypi.org/project/svg.path/
For actually parsing the file, there are a number of options (in the end, it's an XML file and I tend to treat it as such)Re: An SVG is all you need
#48Earlier quoted context omitted.
Can't you do it by hand pretty easily? It's a list of coordinates separated by spaces. For example: "100,100 100,200 200,200 200,100"
No, the specification is more complicated, for example elements (and sub-elements recursively) can have transforms applied to them.
Re: An SVG is all you need
#49Even though the article is mostly talking about visualizations, but I thought I'd share that I did at one point build a dance choreography software that renders the UI entirely SVG. I was surprised as to how well that worked. If you're curious, it's called StageKeep, and you can find it here. https://stagekeep.com/ The original project used React Three Fiber, but refactored it to SVG for reasons I don't quite remembe…
Re: An SVG is all you need
#50I recently found out that it is surprisingly hard to convert an SVG file that consists of series of line segments into a list of those line segments in Python. I tried with ChatGPT and Claude but both were not able to find a solution that respects the entire specification, especially transforms. Initially, my expectation was that there must be a library for this kind of thing, but alas.
I mean - it's XML so you could go that way and extract the d element from path element? But there seems to be a lot of SVG specific tooling and code to do this in python? Eg: https://github.com/RaubCamaioni/svgpath