Closed Pean-Mura closed 3 years ago
Please share some code.
above is the png I got .below is the origin svg
drawing = svg2rlg(file)
renderPM.drawToFile(drawing,out+name+'.png',fmt='PNG')
code just like this, nothing special. but i process 16 imgs continusly. It randomly get the black block on 2 or 3 imgs.
Please share a complete minimal example.
Sorry, but I'm scared of ZIPs. ;) Would you mind putting the SVG on a gist for your GitHub account? (I've just updated the issue template accordingly.)
Sorry, but I'm scared of ZIPs. ;) Would you mind putting the SVG on a gist for your GitHub account? (I've just updated the issue template accordingly.)
okay, I have done. https://gist.github.com/Pean-Mura/9c04ad0c48ad831684da55eca40a8a81
I've had a look at your SVG files using the following snippet to generate PNGs for all:
from glob import glob
from svglib.svglib import svg2rlg
from reportlab.graphics import renderPM
for fn in glob('*.svg'):
drawing = svg2rlg(fn)
out = fn.split('.')[0] + '.png'
renderPM.drawToFile(drawing, out, fmt='PNG')
I can see artifacts near some letters like B in 1.svg and 2.svg, but they don't look like black squares to me. See attached images. The Chinese (?) letters seem to be ignored in the PNG output, and appear with outlined squares in PDF output. This is likely a font issue.
For the artifacts you describe around some letters... I suggest you minimize some SVG example even more to only one letter causing this effect in order to isolate it more.
I've had a look at your SVG files using the following snippet to generate PNGs for all:
from glob import glob from svglib.svglib import svg2rlg from reportlab.graphics import renderPM for fn in glob('*.svg'): drawing = svg2rlg(fn) out = fn.split('.')[0] + '.png' renderPM.drawToFile(drawing, out, fmt='PNG')
I can see artifacts near some letters like B in 1.svg and 2.svg, but they don't look like black squares to me. See attached images. The Chinese (?) letters seem to be ignored in the PNG output, and appear with outlined squares in PDF output. This is likely a font issue.
For the artifacts you describe around some letters... I suggest you minimize some SVG example even more to only one letter causing this effect in order to isolate it more.
Yeah, it's true that chinese characters will be ignored too. Is there anymethod to solve this problem? Or how to use another font?
You can try using a dedicated font and/or find some clues in https://github.com/deeplook/svglib/issues/89.
Please share some code.