meerk40t / svgelements

SVG Parsing for Elements, Paths, and other SVG Objects.
MIT License
132 stars 29 forks source link

Question: What is the "pathname" variable in the Parsing example? #121

Closed Esser50K closed 2 years ago

Esser50K commented 2 years ago

In the README there is a nice example of how to parse the elements of the SVG. But in the last condition there is an unknown variable pathname. I understand this should be the pathname that the nested SVG is pointing to, but it's not written from where to get the variable.

tatarize commented 2 years ago

It would be the file you would be loading in the example. Basically the os.path.dirname(pathname) is supposed to get the working directory. The images in the SVG would be local at times. So you could reference href="myimage.png" in the svg and to load up that image correctly you would need Pillow, but it would be to load things locally if they weren't stored in base64 or whatever.

I might should update that example but it's intended to be the file location. So you can get the working directory and thus locate any referenced graphics. svgelements won't do that for you since looking around for some image seemed weird. But, it needed to be possible.

Esser50K commented 2 years ago

ah thanks for clarifying. I just think that it will be quite common that people will just copy paste that snippet and the os.path.dirname(pathname) may get a bit confusing on how to fix.

tatarize commented 2 years ago

Updated example to clarify