简体   繁体   English

SVG 到 PNG - 线条不可见

[英]SVG to PNG - lines invisible

Problem: some svg drawings open well in chrome and edge but not in inkscape or do not convert well with imagemagick. In my case only the text-labels were shown, no lines or drawings at all.问题:某些 svg 绘图在 chrome 和 edge 中打开良好,但在 inkscape 中打开效果不佳,或者使用 imagemagick 无法很好地转换。在我的例子中,只显示了文本标签,根本没有线条或绘图。

I could not find a solution on stack-overflow or google, the problem seems to occur with others to, but with no answer why and/or with no solution我在 stack-overflow 或 google 上找不到解决方案,问题似乎发生在其他人身上,但没有回答为什么和/或没有解决方案

After a lot of searching, I found the reason why: the colors in my SVG were speficied like this:经过大量查找,我找到了原因:我的 SVG 中的 colors 是这样指定的:

stroke:RGB(0,0,0);

According to the SVG spefication, this seems ok, only the specs mention 'rgb' in lower case.根据 SVG 规范,这似乎没问题,只有规范以小写形式提及“rgb”。 When I converted 'RGB' to 'rgb' in my drawings, they were processed correctly in chrome, edge, inkscape and imagemagick当我将绘图中的“RGB”转换为“rgb”时,它们在 chrome、edge、inkscape 和 imagemagick 中得到了正确处理

My correction in C# as inspiration:我在 C# 中的更正作为灵感:

var allText = File.ReadAllText(fileName);
allText = Regex.Replace(allText, @"RGB\((\d+),(\d+),(\d+)\)", @"rgb($1,$2,$3)");
File.WriteAllText(fileName, allText);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM