clipPath ignored with PNG rendering
Opened this issue · 15 comments
The SVG I have
The PNG it produces
Additionnal context
OS: Windows 10 / Arch Linux (this happens on both)
svglib: 1.1.0
reportlab: 3.6.1
@replabrobin, can you confirm that ReportLab only support Path-like clip paths? Is there anything that would prevent using a circle as a clip path, like in this example image?
Even using a path it doesn't work
Are you really sure? It worked for me.
I tested again and yep, I still get the image of the first post, without masks
Maybe you have a dev version or anything?
No, even when reverting code to 1.1.0, it still works. I have no Windows to test, but I don't see this would make a difference.
I'll test on Linux
The issues is still there for me on Linux
Here are the debug logs
DEBUG:svglib.svglib:Exception during applyStyleOnShape DEBUG:svglib.svglib:Exception during applyStyleOnShape DEBUG:svglib.svglib:Exception during applyStyleOnShape DEBUG:svglib.svglib:Unused attrs: path ['class'] DEBUG:svglib.svglib:Exception during applyStyleOnShape DEBUG:svglib.svglib:Exception during applyStyleOnShape DEBUG:svglib.svglib:Exception during applyStyleOnShape DEBUG:svglib.svglib:Unused attrs: path ['class'] DEBUG:svglib.svglib:Exception during applyStyleOnShape DEBUG:svglib.svglib:Exception during applyStyleOnShape DEBUG:svglib.svglib:Exception during applyStyleOnShape DEBUG:svglib.svglib:Exception during applyStyleOnShape DEBUG:svglib.svglib:Exception during applyStyleOnShape DEBUG:svglib.svglib:Exception during applyStyleOnShape DEBUG:svglib.svglib:Unused attrs: image ['__rules_applied', '{http://www.w3.org/1999/xlink}href'] DEBUG:svglib.svglib:Unused attrs: g ['__rules_applied'] DEBUG:svglib.svglib:Exception during applyStyleOnShape DEBUG:svglib.svglib:Exception during applyStyleOnShape DEBUG:svglib.svglib:Exception during applyStyleOnShape DEBUG:svglib.svglib:Exception during applyStyleOnShape DEBUG:svglib.svglib:Exception during applyStyleOnShape DEBUG:svglib.svglib:Exception during applyStyleOnShape DEBUG:svglib.svglib:Unused attrs: image ['__rules_applied', '{http://www.w3.org/1999/xlink}href'] DEBUG:svglib.svglib:Unused attrs: g ['__rules_applied'] DEBUG:PIL.PngImagePlugin:STREAM b'IHDR' 16 13 DEBUG:PIL.PngImagePlugin:STREAM b'IDAT' 41 41578 DEBUG:PIL.PngImagePlugin:STREAM b'IHDR' 16 13 DEBUG:PIL.PngImagePlugin:STREAM b'IDAT' 41 65536
Claude, so far as I can tell PDF supports clipping with paths and in canvas.py we use a path to create ellipse/circle So at least in principle it ought to be possible to mask using a circle. Unfortunately the canvas api doesn't make this terribly easy as the canvas circle/ellipse methods don't return the created path and don't have a render mode to allow easier specification of the rendering. On the other hand one can create the path with path.ellipse(....) and then just use canvas.clipPath on the result
With PDF, path clips work, but circle ones don't. And for PNG both don't work. So what we need to figure out is why path clips don't work in PNG
Ah sorry, indeed I only tested PDF rendering. I admit I don't care so much for PNG (not in my use cases).
On the other hand one can create the path with path.ellipse(....) and then just use canvas.clipPath on the result
Thanks for this tip. I think we should able to support at least Circles with that trick.
Ah sorry, indeed I only tested PDF rendering. I admit I don't care so much for PNG (not in my use cases).
So, with PNG, does the issue also happen on your device?
Hi Victor, unfortunately the renderPM/PDF/PS/SVG csnvasses sre all slightly different.from the original pdfgen/canvas.py code. The shapes.path class does allow isClipPath to be set so if png is not obeying the setting then presumably we will have to mess with the renderPM canvas/renderer classes to amke it work.