deeplook / svglib

Read SVG files and convert them to other formats.
GNU Lesser General Public License v3.0
324 stars 79 forks source link

SVG file from Google Presentation won't parse #306

Closed tobyclh closed 2 years ago

tobyclh commented 2 years ago

Hi

I have some files from exported from Google presentation that cannot be parse for some reason.

drawing = svg2rlg(args.input)

Log

    drawing = svg2rlg(args.input)
  File "/home/anaconda3/envs/makeup/lib/python3.8/site-packages/svglib/svglib.py", line 1436, in svg2rlg
    drawing = svgRenderer.render(svg_root)
  File "/home/anaconda3/envs/makeup/lib/python3.8/site-packages/svglib/svglib.py", line 544, in render
    main_group = self.renderSvg(node, outermost=True)
  File "/home/anaconda3/envs/makeup/lib/python3.8/site-packages/svglib/svglib.py", line 819, in renderSvg
    self.renderNode(child, group)
  File "/home/anaconda3/envs/makeup/lib/python3.8/site-packages/svglib/svglib.py", line 575, in renderNode
    item = self.renderG(n, clipping=clipping)
  File "/home/anaconda3/envs/makeup/lib/python3.8/site-packages/svglib/svglib.py", line 853, in renderG
    item = self.renderNode(child, parent=gr)
  File "/home/anaconda3/envs/makeup/lib/python3.8/site-packages/svglib/svglib.py", line 575, in renderNode
    item = self.renderG(n, clipping=clipping)
  File "/home/anaconda3/envs/makeup/lib/python3.8/site-packages/svglib/svglib.py", line 853, in renderG
    item = self.renderNode(child, parent=gr)
  File "/home/anaconda3/envs/makeup/lib/python3.8/site-packages/svglib/svglib.py", line 587, in renderNode
    item = self.renderG(n)
  File "/home/anaconda3/envs/makeup/lib/python3.8/site-packages/svglib/svglib.py", line 853, in renderG
    item = self.renderNode(child, parent=gr)
  File "/home/anaconda3/envs/makeup/lib/python3.8/site-packages/svglib/svglib.py", line 607, in renderNode
    item = self.shape_converter.convertShape(name, n, clipping)
  File "/home/anaconda3/envs/makeup/lib/python3.8/site-packages/svglib/svglib.py", line 930, in convertShape
    shape = getattr(self, method_name)(node)
  File "/home/anaconda3/envs/makeup/lib/python3.8/site-packages/svglib/svglib.py", line 1166, in convertPath
    xn, yn = points[-2] + nums[0], points[-1] + nums[1]
IndexError: list index out of range

Screenshot of the SVG

image

If I change xn, yn = points[-2] + nums[0], points[-1] + nums[1] to xn, yn = points[-2] + nums[0], points[-1] + nums[-1] it will parse but will produce an incorrect result.

Incorrect result

The middle image is offset a bit wrong somehow? image

Link to the said SVG

github-actions[bot] commented 2 years ago

Thank you for raising your first issue! Your help to improve svglib is much appreciated!

claudep commented 2 years ago

I cannot reproduce the error with svglib master. Can you tell us which version of svglib you are using?

tobyclh commented 2 years ago

I was using the version on pop on Ubuntu 20.04. I will report back again later after trying out master. Thank you! On Fri, Dec 24, 2021 at 17:19 Claude Paroz @.***> wrote:

I cannot reproduce the error with svglib master. Can you tell us which version of svglib you are using?

— Reply to this email directly, view it on GitHub https://github.com/deeplook/svglib/issues/306#issuecomment-1000718227, or unsubscribe https://github.com/notifications/unsubscribe-auth/AC7MH2YZXFYG2WNUQGQRYNLUSQUJHANCNFSM5KWEBT5A . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you authored the thread.Message ID: @.***>

tobyclh commented 2 years ago

Upon building it from master the issue resolves. Thank you!