Code Monkey home page Code Monkey logo

Comments (12)

claudep avatar claudep commented on August 17, 2024

Is the PDF rendering also similarly broken?
It would be awesome to isolate and extract the wrongly-rendered polygons from the SVG.

from svglib.

deeplook avatar deeplook commented on August 17, 2024

@eyaler Don't hesitate to post a bitmap image in a ticket! I at least find sites like ibb.co a little suspicious. ;-)

from svglib.

deeplook avatar deeplook commented on August 17, 2024

Anybody have a pointer to some text about reporting issues and/or making contributions? I feel like we have too many issues recently with either confusing titles, insufficient information and/or desired outcome, or a combination of these...

from svglib.

claudep avatar claudep commented on August 17, 2024

I was able to reproduce with this minimal svg:
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="224" height="124"> <polygon class="#AC2F75" fill="#AC2F75" points="122,87 122,88 123,88 123,89 124,89 124,90 126,90 126,89 128,88 128,89 129,89 129,91 128,91 128,92 130,99 130,100 129,100 126,103 125,103 125,104 126,106 130,87 129,87 129,86 126,86 126,87"/> </svg>

If I remove the main_group.scale/main_group.translate ops in SvgRenderer.render, the artifact doesn't appear (but then the image is mirrored, of course). Looks like an issue in ReportLab. I can reproduce with this pure ReportLab code:

from reportlab.lib import colors
from reportlab.graphics.shapes import Drawing, Group, Polygon
from reportlab.graphics import renderPM
d = Drawing(224, 124)
points = [122.0, 87.0, 122.0, 88.0, 123.0, 88.0, 123.0, 89.0, 124.0, 89.0, 124.0, 90.0, 126.0, 90.0, 126.0, 89.0, 128.0, 88.0, 128.0, 89.0, 129.0, 89.0, 129.0, 91.0, 128.0, 91.0, 128.0, 92.0, 130.0, 99.0, 130.0, 100.0, 129.0, 100.0, 126.0, 103.0, 125.0, 103.0, 125.0, 104.0, 126.0, 106.0, 130.0, 87.0, 129.0, 87.0, 129.0, 86.0, 126.0, 86.0, 126.0, 87.0]
grp = Group(Polygon(points, fillColor=colors.red))
grp.scale(1, -1)
grp.translate(0, -124)
d.add(grp)
renderPM.drawToFile(d, 'example1.png', fmt="PNG")

from svglib.

deeplook avatar deeplook commented on August 17, 2024

@replabrobin Robin, any idea if this is really an issue with reportlab? Thanks!

from svglib.

replabrobin avatar replabrobin commented on August 17, 2024

I think this is almost certainly an issue with the underlying libart library which we use to render the images. It looks as though the fill scanlines are just escaping from the confining polygon. In debian at least they want to abandon libart. I updated to latest debian code recently and found one (possibly serious) difference to the code which we have carried around for ages.

Oddly the problem disappears when the scaling and translation are removed so this is probably a numerical issue. Our code is slightly different to the debian code as we modify to clean up a lot of compiler warnings in the windows build. I will try the unmodified debian code to see if the problem is still there. I don't think this is a winding number issue.

from svglib.

replabrobin avatar replabrobin commented on August 17, 2024

The latest release of reportlab 3.5.5 contains a probabilistic fix, Looking in the code it seems randomization is a standard way to fix stability issues. Hope it works for svglib.

from svglib.

Overdrivr avatar Overdrivr commented on August 17, 2024

I can confirm similar issues with horizontal lines randomly appearing on rendered images. I'm running Windows 10.
This is how one of our svg documents look like in Inkscape (looks same in Chrome):

image

And this is how svglib renders it:

ht_mask

You can find the SVG attached here:

mask.zip

Do you have an idea of a workaround ?

from svglib.

replabrobin avatar replabrobin commented on August 17, 2024

I'm not sure that this problem is the same issue. The original issue was with png rendering and relates to _renderPM.c; this error is happening in PDF rendering. It looks more like a structural issue decoding the SVG into RL graphics.

If you can make a minimal example that shows the issue I would raise it anew.

from svglib.

claudep avatar claudep commented on August 17, 2024

I wasn't able to reproduce, are you sure you are using latest svglib?

from svglib.

Overdrivr avatar Overdrivr commented on August 17, 2024

@replabrobin My issue is with PNG rendering, not PDF, should be the same issue no ?

I'm using svglib 0.9.2, reportlab version is 3.5.23 (can confirm with latest 3.5.26), this is the code I'm using:

from svglib.svglib import svg2rlg
from reportlab.graphics import renderPM
drawing = svg2rlg(filename)
renderPM.drawToFile(drawing, dest, fmt="PNG")

I realize now, maybe this comes from reportlab ? Could you share the code you're using @claudep ?

from svglib.

claudep avatar claudep commented on August 17, 2024

Oh, sorry, I was testing the PDF output, which looks fine.

from svglib.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.