Closed eddex closed 2 years ago
Thank you for raising your first issue! Your help to improve svglib is much appreciated!
Can't handle color
is a warning, not an error. Is that a problem?
svglib (and ReportLab) doesn't support gradients, that's a documented limitation.
The problem is that the data is missing and I can't use the loaded svg. But if this is a known limitation, it's ok. I can flatten the gradient into an image as described above.
Unfortunately that's the right workaround, waiting for gradient support in ReportLab.
Can we detect when this happens so we know the resulting drawing is incorrect? Often I get a blank or very deformed image. I'd like to raise an exception if this happens so I can substitute a default image.
I wrote a script to remove the gradients in the svg file. It certainly deserves some polishing, and there is no color averaging implemented yet, but it works such that you still have a vectorized graphic.
Interesting, thanks. I guess something like that could be integrated in svglib (storing linear def node ids while iterating nodes, and replacing url()
by a fill color when appropriate. Exercise left for the reader :smile:
Description When I try to open an svg file that contains a gradient, the
svg2rlg
method throws an error sayingCan't handle color: url(#_Linear1)
.Steps to reproduce
Workaround
When I flatten the svg during export, thus replacing the
<linearGradient>
element with an<image>
element, the svg can be loaded: