Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SVG file with transform leads to inconsistency between viewBox and path coordinates #189

Open
g3grau opened this issue Nov 12, 2022 · 1 comment

Comments

@g3grau
Copy link

g3grau commented Nov 12, 2022

I'm trying to read SVG files which were created with potrace using a scaling parameter -u 10. This results in a SVG with a transform group (translation 0, 0, scale 0.1, -0.1). I figured out that the path coordinates are all 10x larger than expected from reading the viewBox in svg_attributes, thus I wanted to get at least the information if a scale transform has been defined in the file. I could not find a way to extract this using the API and ended in an ugly index-search for "scale(" and the following ")" in str(svgpathtools.Document(file)) to get these numbers. Is there a more elegant way to get this transform info? I thought it might be a "group" since it's in a g tag, but I couldn't get Document(file).contains_group or get_group to work.

I have seen a fork which attempts to "flatten" the transform, but I think this has not been merged. Would it be an alternative
to transform the viewBox instead of the paths and add translate/scale items to svg_attributes?

@bcwhite-code
Copy link

I'm seeing this, too. The SVG has

<g transform="translate(0.000000,512.000000) scale(0.100000,-0.100000)">

Inkscape reports the coordinates as 0,0 to 1000,1000 but the segments returned by this library are in the range of 90.8, -4793.8 to 9901.1, 5028.2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants