Page 1 of 1

Only black rectangle on PNG converted from simple SVG code in newer version of ImageMagick

Posted: 2019-01-22T03:35:53-07:00
by Gim6626
I've upgraded ImageMagick with my Ubuntu from 8:6.8.9.9-7ubuntu5.13 and 16.04 to 8:6.9.10.8+dfsg-1ubuntu2 and 18.10 and faced strange issue. Simple test SVG code now fails to convert to PNG and shows only black rectangle.

Here is SVG code:

Code: Select all

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg width="500" height="300" xmlns="http://www.w3.org/2000/svg">
  <title>Singleton Pattern</title>
  <defs>
    <style type="text/css">
      <![CDATA[
        g{
          stroke       : #000;
        }
        rect, path, circle{
          fill         : #fff;
          fill-opacity : 0;
        }
        rect{
          stroke-width : 6;
        }
        path, circle, line{
          stroke-width : 2;
        }
        text{
          fill         : #000;
          stroke-width : 0;
          font-family  : sans-serif;
          font-size    : 25px;
        }
        text.name{
          fill         : #000;
          stroke-width : 0;
          font-weight  : bold;
          text-anchor  : middle;
          font-family  : sans-serif;
          font-size    : 25px;
        }
        text.visibility{
          fill         : #000;
          stroke-width : 0;
          font-size    : 28px;
          font-family  : monospace;
          font-weight  : bold;
          text-anchor  : middle;
        }
      ]]>
    </style>
  </defs>
  <g transform="translate(50,50)">
    <rect width="400" height="200" />
    <line x1="0" x2="400" y1="60"  y2="60" />
    <line x1="0" x2="400" y1="110" y2="110" />
    <text x="200" y="45"  class="name">Singleton</text>
    <text x="30"  y="95"  class="visibility">-</text>
    <text x="60"  y="95">singleton : Singleton</text>
    <line x1="30" x2="370" y1="100" y2="100" />
    <text x="30"  y="145" class="visibility">-</text>
    <text x="60"  y="145">Singleton()</text>
    <text x="30"  y="180" class="visibility">+</text>
    <text x="60"  y="180">getInstance() : Singleton</text>
    <line x1="30" x2="370" y1="185" y2="185" />
  </g>
</svg>
I use simple command for conversion:

Code: Select all

convert foo.svg foo.png
Here is PNG created from it on 8:6.8.9.9-7ubuntu5.13 (Ubuntu 16.04):
Image

And here is PNG from newer 8:6.9.10.8+dfsg-1ubuntu2 (Ubuntu 18.10):
Image

Online tools like https://svgtopng.com work perfectly, it makes me think that SVG code is correct. Also my SVG example is taken from https://en.wikipedia.org/wiki/Singleton ... iagram.svg and are shown in browser correctly, which also make me think that problem is not in SVG.

Could anybody help to make newer version work? Or maybe there is some bug in it?

Re: Only black rectangle on PNG converted from simple SVG code in newer version of ImageMagick

Posted: 2019-01-22T13:23:51-07:00
by fmw42
Your images cannot be accessed. Please fix your links.

Re: Only black rectangle on PNG converted from simple SVG code in newer version of ImageMagick

Posted: 2019-01-22T20:40:37-07:00
by Gim6626
fmw42 wrote: 2019-01-22T13:23:51-07:00 Your images cannot be accessed. Please fix your links.
Sorry. Fixed.

Re: Only black rectangle on PNG converted from simple SVG code in newer version of ImageMagick

Posted: 2019-01-22T20:51:46-07:00
by snibgo
What delegate renders the SVG? I expect Inkscape should be okay, but MSVG almost certainly can't process the embedded CSS.

Re: Only black rectangle on PNG converted from simple SVG code in newer version of ImageMagick

Posted: 2019-01-22T22:32:07-07:00
by Gim6626
snibgo wrote: 2019-01-22T20:51:46-07:00 What delegate renders the SCG?
Sorry, but I don't undestand your question. Could you explain it?
snibgo wrote: 2019-01-22T20:51:46-07:00 I expect Inkscape should be okay, but MSVG almost certainly can't process the embedded CSS.
Inkscape shows file correctly.

Re: Only black rectangle on PNG converted from simple SVG code in newer version of ImageMagick

Posted: 2019-01-23T01:20:48-07:00
by Gim6626
Could not reproduce this bug anymore. Don't understand what happened.

Re: Only black rectangle on PNG converted from simple SVG code in newer version of ImageMagick

Posted: 2019-01-23T01:23:36-07:00
by fmw42
snibgo wrote: ↑Tue Jan 22, 2019 7:51 pm
What delegate renders the SCG?
Sorry, but I don't undestand your question. Could you explain it?
SVG files are vector files and Imagemagick uses some other tool to convert them to raster images.

He is asking what renderer you are using to convert the vector SVG file into a raster image? Imagemagick can use Inkscape, the RSVG delegate and the internal Imagemagick MSVG/XML renderer, in order of decreasing quality for the result. If you have not installed Inkscape, it will RSVG if you installed that. Otherwise, it will use MSVG/XML.

You can find out which of the latter, by

convert -list format

and look at the end of the line for SVG. It will say RSVG or XML. But if Inkscape is installed it will not show that.

Alternately, just add -verbose to your command line and it will show the renderer and the command used by the renderer.

Re: Only black rectangle on PNG converted from simple SVG code in newer version of ImageMagick

Posted: 2019-01-23T01:24:36-07:00
by fmw42
Gim6626 wrote: 2019-01-23T01:20:48-07:00 Could not reproduce this bug anymore. Don't understand what happened.
Once Inkscape is installed and it worked once, it will work again. So it is likely that you are now using Inkscape to render all SVG files.