Commons:Graphics village pump/June 2020

From Wikimedia Commons, the free media repository
Jump to navigation Jump to search

Uploaded an SVG, but it just shows up as a green box

I've been working on an SVG template for creating images of tartan patterns, and I uploaded my test document, but it just shows up as a green box. I've uploaded about 8 different versions of the file so far with no luck. I've tried adding explicit tags that aren't officially necessary (e.g. <defs>), varying all sorts of parameter calls, and anything else I could think of with no effect. When I click on the image and get the bare SVG file, it is perfect, but the PNG converter seems to be balking at something. As best as I can tell, it is taking the last (top) line defined for the fill pattern, ignoring the stroke-dasharray parameter that would allow content from lower layers to show through, so all you can see is the top layer. The file has passed the W3C markup validation service without any errors. Anyone want to take a look and see if we can't figure out what's going wrong? Vanisaac (talk) 19:17, 23 June 2020 (UTC)

So I got clued in on that there are issues with using masks in commons. So I went on a crusade to try to track down the bug in phabricator, but the proffered solution at [1] didn't fix my issue. The main issue was a problem interpreting the stroke-dasharray parameter on all my <line>s. Apparently librsvg sometimes balks at spaces in dasharrays, but you can just replace them with commas. I did end up using the manual values to bypass the bug T55899 at the cost of a few bytes, but it definitely works. You can see all my attempts at tracking down the issues in the file history at File:SVG Black Watch Tartan test file.svg. In the end, I was able to describe the Black Watch tartan in 1248 bytes, so I'm feeling good, even though it took me 17 tries to get a file that commons would interpret correctly. Vanisaac (talk) 05:45, 24 June 2020 (UTC)
After some more optimization, mostly removing redundant space characters, I got it down to 1155 bytes. And the maskUnits workaround (using "-10% -10% 120% 120%" instead of "userSpaceOnUse") did end up being necessary. VanIsaac (en.wiki) 19:01, 24 June 2020 (UTC)