Open razzeee opened 8 months ago
The first one works just fine with the latest resvg
. The second doesn't, because of /
before the alpha. We do not support such notation yet. Prefer rgba(0 0 0 0.07)
and it will work fine.
Most of the stuff from CSS Color Module Level 4 isn't supported. We target Level 3 for now.
I guess https://github.com/yisibl/resvg-js using 0.34 is a problem then. I at least can't get it to work with rgba(0 0 0 0.07)
But my source image also fails to generate a shadow in the svg version, unless I add the commas for rgba "drop-shadow(0 4px 3px rgba(0, 0, 0, 1)) drop-shadow(0 2px 2px rgba(0, 0, 0, 1))",
Commas are optional. It should work without them.
If resvg
CLI renders your SVG fine - then it's resvg-js
bug. And resvg-js
is an independent project. I have no affiliation with it.
Tested with latest version of the cli and it fails with
Warning (in usvg::parser::filter:93): Failed to parse a filter value cause unexpected end of stream. Skipping.
With this svg
<svg width="258" height="258" viewBox="0 0 258 258" xmlns="http://www.w3.org/2000/svg"><mask id="satori_om-id"><rect x="0" y="0" width="258" height="258" fill="#fff"/></mask><rect x="0" y="0" width="258" height="258" fill="#E8F8FF"/><mask id="satori_om-id-0"><rect x="0" y="0" width="258" height="232" fill="#fff"/></mask><mask id="satori_om-id-0-0"><rect x="-21" y="-12" width="300" height="256" fill="#fff"/></mask><clipPath id="satori_cp-id-0-0-0"><path x="1" y="-12" width="256" height="256" d="M17,-12 h224 a16,16 0 0 1 16,16 v224 a16,16 0 0 1 -16,16 h-224 a16,16 0 0 1 -16,-16 v-224 a16,16 0 0 1 16,-16"/></clipPath><mask id="satori_om-id-0-0-0"><rect x="1" y="-12" width="256" height="256" fill="#fff"/></mask><image x="1" y="-12" width="256" height="256" href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAIAAAACACAYAAADDPmHLAAAABHNCSVQICAgIfAhkiAAADlxJREFUeJztXU1sG8cZfbsSRVKuLdkmRVlxKslNLOXn4FBqYkdyiqDH3lq0SIKihZwEraVUTpFbgfbQS3soYjmI7RT5ERo0aFAgQNNLL0Xb2JKctBZziy25Ra3UkUhLgUgz5q92pgdyFZrm7g53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5EPeCQCanHw4EHHWwd+JR/woAAAZ0XgZ/IBD0ZALVZWVgynoVnpMWSYrqUA8Cz5gMcFALCJwExNwFrte5l8wKMRUIv+/n7dMYZm4qBVyAd8IACArwhaiXzABxFQi5WVFUs9hizkE0JODAwM+IJ8wCcOoKK/v5+px3CogRO0IvmAzxxAhZET5LYofntlExfWKgNMnziwCz96YC86tRcK9CX5gE8FABiLoAn4lnzAxwIAKiKAtbmICqXUt+QDPqsB6tHf329lVrLvyQd8LgBguzCcgMbOJxooE0J+6HfygRYQAAAMDAy8TSn9JoBrDG9fIoR8c3Bw8B27r0sEtIQAAGBgYODC559//pCiKM8QQv5MKU3VTNNKEULeVxTl6evXrz88ODh40e3rdQq+LgKNoG6nqrepkt/R0gLYQQtFwA4aY0cALY4dAbQ4dgTQ4vg/0opFCDOpCXIAAAAASUVORK5CYII=" preserveAspectRatio="none" style="filter:drop-shadow(0 4px 3px rgba(0, 0, 0, 0.5))" clip-path="url(#satori_cp-id-0-0-0)" mask="url(#satori_om-id-0-0-0)"/></svg>
Definitely a bug in resvg
. For some reason the double closing quote trips up the value parser. If you replace it with something like "black" it works. The value of the filter attribute gets parsed as "drop-shadow(0 4px 3px rgba(0, 0, 0, 0.5)"
, even though in the original SVG there are two closing brackets.
Seems to be a bug in simplecss
if I'm not wrong.
Here is the culprit: https://github.com/RazrFalcon/simplecss/blob/37ddffef48bd8597347284c94e219bd69263f316/src/lib.rs#L510-L514
We simply iterate until we find the first closing bracket, which won't work if they are nested...
I guess https://github.com/yisibl/resvg-js using 0.34 is a problem then. I at least can't get it to work with
rgba(0 0 0 0.07)
But my source image also fails to generate a shadow in the svg version, unless I add the commas for rgba
"drop-shadow(0 4px 3px rgba(0, 0, 0, 1)) drop-shadow(0 2px 2px rgba(0, 0, 0, 1))",
Please note that even in CSS Color Level 4, rgba(0 0 0 0.07)
is incorrect syntax. When using an alpha value, it needs to be separated by a /, like this: rgba(0 0 0 / 0.07)
.
However, when submitting an issue to resvg, please use the color syntax from CSS Color Level 3. I even recommend always prioritizing Color Level 3 syntax in SVG because it has better compatibility.
@LaurenzV Yeah... it's a CSS2 parser for a reason. Will see how to fix it.
As a hotfix you can use #rrggbbaa
notation. It should work fine.
Hey, I'm trying to use a drop shadow in a style element like
or even better
But when converting from svg to png via resvg the shadows are lost
It should be reproduceable with
https://github.com/yisibl/resvg-js/issues/317