Re: Issue with element superposition when converting SVG to PNG

"Philippe Renault" <[email protected]> Mon, 12 Jul 2021 18:17:41 +0200
Newsgroups gmane.comp.python.reportlab.user
Message-ID <[email protected]>
Dear reportlab community

I've implemented reportlab in a python script to convert a generated SVG to
PNG to afterwards display it on a display in my smarthome.

Nevertheless, I've been struggling for a long time now to figure out an
issue during the conversion process which I can't resolve.

In the python script I'm using the following basic commands to generate the
PNG:

 

from svglib.svglib import svg2rlg 

from reportlab.graphics import renderPM 

from PIL import Image

.

codecs.open(SVG_OUTPUT, "w", encoding="utf-8").write(output)

drawing = svg2rlg(SVG_OUTPUT)  # Convert SVG to regular expression

renderPM.drawToFile(drawing, TMP_OUTPUT, fmt="PNG") # Convert SVG to PNG

 

Attached you will find the input SVG I'm using
(cron_kindle-weather_output.svg) and the output generated by the
renderPM.drawToFile (weatherdata-dg-whz_withMarkups.png). As you can see
there is a superposition of elements in a few places which I don't
understand why this happens. If I use eg. Inkscape to convert to PNG the
figure is ok. Also if I use an online-converter like e.g. SVGTOPNG.com the
output looks fine.

Does anybody have an idea or a lead to why this is happening and how to fix
it?

Thank you very much in advance for support.

Best regards

Philippe
Attachment-IssueIllustration.zip (application/x-zip-compressed, 57.7 KB) - not displayed