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

More robust svg parser :) #17

Open
kelisiya opened this issue Jan 15, 2021 · 2 comments
Open

More robust svg parser :) #17

kelisiya opened this issue Jan 15, 2021 · 2 comments

Comments

@kelisiya
Copy link

Thank you for your work and contribution ! but when I want to process my datasets , it's not work .
Can you support more SVG methods looks like svgpathtools?
Two error svg data samples :
<svg class="icon" height="1024px" p-id="37334" style="" version="1.1" viewbox="0 0 1191 1024" width="1191px" x="0px" xmlns="http://www.w3.org/2000/svg" y="0px"> <path d="M1167.959613 65.770695c-0.996526 0 0 0 0 0-40.857553-61.784593-115.59698-83.708158-168.412841-49.826284 0 0-122.57266 84.704683-274.044564 195.319035L149.510361 39.861027c-23.916616-6.97568-39.861027 22.920091-20.92704 38.864502l356.756196 315.898643C393.659154 469.363599 307.957945 541.113448 249.162929 596.918887c-1.993051 1.993051-3.986103 2.989577-6.975679 1.993051L52.847369 528.158614C9.996765 511.217678-19.899006 568.019642 15.975919 594.925835l155.458007 113.603929 39.861027 188.343354c8.968731 44.843656 73.742901 39.861027 76.732478-4.982628l13.95136-202.294714c0-2.989577 1.993051-4.982628 3.986103-5.979155 75.735952-30.892296 174.391995-78.725529 280.023718-132.537916L727.495259 1007.48747c6.97568 23.916616 40.857553 20.927039 44.843656-2.989577L853.057496 408.575532c163.430213-91.680363 290.985501-168.412841 290.985501-168.412841 51.819336-33.881873 62.781118-112.607403 23.916616-174.391996z m-67.763747 145.492751l-26.906193 17.937462-93.673415-145.49275 26.906194-17.937463c37.867976-23.916616 87.69426-12.954834 111.610877 23.916617l5.979154 8.968731c24.913142 37.867976 13.95136 87.69426-23.916617 112.607403z m67.763747-145.492751c-0.996526 0 0 0 0 0z" fill="#FE8950" p-id="37335"> </path> </svg>
<svg class="icon" height="1024px" p-id="37323" style="" version="1.1" viewbox="0 0 1024 1024" width="1024px" x="0px" xmlns="http://www.w3.org/2000/svg" y="0px"><path d="M871.1 642.1c27.7-31.9 40.8-60.8 30.7-72.9-7-8.4-23.9-7.2-45.7 1.4l-7.7-36.5c24.6-30.7 35.2-58.1 24.7-71.1-6.8-8.5-21.5-9.5-40.6-4.5l-20.2-95.9C931 221.9 980.1 104.6 949.4 73.9c-30.7-30.7-148 18.4-288.8 137.1l-95.9-20.2c5-19.1 4-33.8-4.5-40.6-13-10.5-40.4 0.1-71.1 24.7l-36.5-7.7c8.6-21.8 9.8-38.7 1.4-45.7-12.1-10.1-41 3-72.9 30.7L237.7 122l-76.9 76.9 132 68.2c-11.3 25.1-13.7 45-4.4 52.7 10.9 9.1 35.1-0.5 63-22.5l32.2 16.6c-10.8 27.5-12.1 49.1-1.2 57.9 12.7 10.2 39 0.3 68.8-23l45.4 23.4c-1.3 1.5-2.7 3-4 4.5-85 96.8-161.2 187.6-216.9 262.9L122.4 622l-57.7 57.7 135.6 77c-18.6 37.2-23.5 64-10.6 76.9 12.9 12.9 39.7 8 76.9-10.6l77 135.6 57.7-57.7-17.7-153.3c75.3-55.7 166.1-131.9 262.9-216.9 1.5-1.3 3-2.7 4.5-4l23.4 45.4c-23.3 29.8-33.2 56.1-23 68.8 8.7 10.9 30.4 9.5 57.9-1.2l16.6 32.2c-22 27.9-31.5 52.1-22.5 63 7.7 9.3 27.6 6.8 52.7-4.4l68.2 132 76.9-76.9-30.1-143.5z m0 0" p-id="37324"></path></svg>

@pwichmann
Copy link

What exactly is the specific problem you encounter?

@kelisiya
Copy link
Author

What exactly is the specific problem you encounter?

I found the error is svglib/svg.py only support 'viewBox' and not support 'viewbox' .
We can change approximately line 124 in from_str fuctiion:
if len(svg_root.getAttribute("viewBox").split(" ")) == 1 : viewbox_list = list(map(float, svg_root.getAttribute("viewbox").split(" "))) else : viewbox_list = list(map(float, svg_root.getAttribute("viewBox").split(" ")))

rjadr added a commit to rjadr/deepsvg that referenced this issue Jul 30, 2022
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