Kozea / Kozea/CairoSVG

ValueError: could not convert string to float: 'null'

Open
#422 1 comment 0 reactions 0 assignees View on GitHub
feature
Dominant language
Python
Stars
951
Forks
166
PR merge metrics
No merged PRs in 30d

Description

Hello,

I get the below error when I try to convert my svg data to png
```
File [~\pythonEnv\lib\site-packages\cairosvg\surface.py:410](http://localhost:8888/lab/tree/GraphDL/~/pythonEnv/lib/site-packages/cairosvg/surface.py#line=409), in Surface.draw(self, node)
407 pass
409 # Get stroke and fill opacity
--> 410 stroke_opacity = float(node.get('stroke-opacity', 1))
411 fill_opacity = float(node.get('fill-opacity', 1))
412 if opacity < 1 and not node.children:

ValueError: could not convert string to float: 'null'
```

I was wondering how I can fix it?

best

Contributor guide

No contributing guide indexed for this repository

Research direction

Start at cairosvg/surface.py around line 410, where the traceback shows stroke opacity is converted during SVG-to-PNG rendering. Obtain or recreate the SVG that produces the 'null' value, then trace how that attribute reaches this code. Done means the reported SVG converts successfully and the behavior is covered by a regression test.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
computer-graphics
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.