deeplook/svglib

stroke-opacity not supported?

Closed this issue · 2 comments

Seems that stroke-opacity is not supported? It always defaults to "1"

import lxml
from lxml.html import open_in_browser
import reportlab.graphics.renderPM
from svglib import svglib
SVG = """
<svg width="100" height="100">
    <circle cx="50" cy="50" r="40" fill="green" stroke="black" stroke-width="5"/>
    <path stroke="red" d="M10 50 90 50" stroke-opacity="0.5" stroke-width="10"/>
</svg>"""
parser = lxml.etree.XMLParser(recover=True, resolve_entities=False)
svg_root = lxml.etree.fromstring(SVG, parser=parser)
open_in_browser(svg_root)
renderer = svglib.SvgRenderer('test')
drawing = renderer.render(svg_root)
pil_image = reportlab.graphics.renderPM.drawToPIL(drawing)
pil_image.show()

chrome Chrome
svglib svglib

I see there is a test for it which indicates it is preserved:

def test_stroke(self):

Have you tried that?

It does render mostly ok to a PDF file.
This seems to indicate a problem with the reportlab renderPM instead. I'll close this bug.

pdf
pdfclose