Page 1 of 1

convert svg weird result image

Posted: 2016-11-04T01:22:00-07:00
by jgonera
Version info:

- ubuntu 16.04.1 LTS
- librsvg2-dev 2.40.13-3

Code: Select all

-> convert -version
Version: ImageMagick 6.8.9-9 Q16 x86_64 2016-06-01 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2014 ImageMagick Studio LLC
Features: DPC Modules OpenMP
Delegates: bzlib cairo djvu fftw fontconfig freetype jbig jng jpeg lcms lqr ltdl lzma openexr pangocairo png rsvg tiff wmf x xml zlib
Invocation:

Code: Select all

wget https://dl.dropboxusercontent.com/u/7581847/logo.svg
convert logo.svg logo.png
No errors are reported by the convert command. The logo.png result image is out of whack.

Expected:
Image

Actual:
Image

Re: convert svg to png fails

Posted: 2016-11-04T01:40:58-07:00
by fmw42
Post your svg file to some place such as dropbox.com and put the URL here. What error message do you get? What version of RSVG do you have?

Re: convert svg to png fails

Posted: 2016-11-04T01:50:18-07:00
by jgonera
fmw42 wrote:Post your svg file to some place such as dropbox.com and put the URL here. What error message do you get? What version of RSVG do you have?
So that wget command i posted isn't working? I updated my post with librsvg version info.

Re: convert svg weird result image

Posted: 2016-11-04T02:11:41-07:00
by snibgo
Inkscape doesn't show your "expected" output. Perhaps your SVG file contains something weird, eg non-valid SVG. In such cases, different renderers make "best-guess" attempts.

Re: convert svg weird result image

Posted: 2016-11-04T02:19:42-07:00
by jgonera
Any way to validate an svg with imagemagick?

Re: convert svg weird result image

Posted: 2016-11-04T08:17:29-07:00
by gringo974
Hi there!

First, it seems the RSVG lib (2.40.15 for me) fails to handle the <style> tag.
If you remove the <style> in your logo.svg file, Chrome renders it as the IM convert (full black).

Here is a unit test for <style> tag:

Code: Select all

<svg width="80" height="80" xmlns="http://www.w3.org/2000/svg"
    xmlns:xlink="http://www.w3.org/1999/xlink">
  <style>
    .classA {
      fill: red;
    }
  </style> 
  <defs>
    <g id="Port">
      <circle style="fill: inherit;" r="10"/>
    </g>
  </defs>
 
  <text y="15">black</text>
  <use x="50" y="10" xlink:href="#Port" />
  <text y="35">red</text>
  <use x="50" y="30" xlink:href="#Port" class="classA"/>
  <text y="55">blue</text>
  <use x="50" y="50" xlink:href="#Port" style="fill: blue;"/>
</svg>
RSVG fails to renders the red circle because it uses style.
Inkscape manages to render it properly.
Should we report that to the RSVG guys?

But, in your case, your file should contain other errors because even Inkscape fails to render it properly.

Re: convert svg weird result image

Posted: 2016-11-04T08:40:02-07:00
by gringo974
After having a look on the rsvg bug reports, this is a known bug:
Styles are ignored in librsvg. Adding type="text/css" to the style element fixes it
Your converted file looks much better after adding this (<style type="text/css">).