CairoSVG icon indicating copy to clipboard operation
CairoSVG copied to clipboard

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

Open bpfrd opened this issue 1 year ago • 1 comments

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

bpfrd avatar Apr 23 '24 07:04 bpfrd

That’s probably because CairoSVG doesn’t handle percentages for opacity. The solution is to allow them everywhere we parse *-opacity properties.

liZe avatar Apr 23 '24 12:04 liZe