deeplook / svglib

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

stroke-opacity not supported? #303

Closed cbeytas closed 3 years ago

cbeytas commented 3 years ago

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

deeplook commented 3 years ago

I see there is a test for it which indicates it is preserved: https://github.com/deeplook/svglib/blob/64c49440dc57104768e2c9e7d8337c68c010e1c8/tests/test_basic.py#L446

Have you tried that?

cbeytas commented 3 years ago

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