convert svg weird result image

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
Post Reply
jgonera
Posts: 6
Joined: 2011-08-03T07:20:29-07:00
Authentication code: 8675308

convert svg weird result image

Post by jgonera » 2016-11-04T01:22:00-07:00

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
Last edited by jgonera on 2016-11-04T02:00:56-07:00, edited 5 times in total.

User avatar
fmw42
Posts: 25657
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: convert svg to png fails

Post by fmw42 » 2016-11-04T01:40:58-07:00

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?

jgonera
Posts: 6
Joined: 2011-08-03T07:20:29-07:00
Authentication code: 8675308

Re: convert svg to png fails

Post by jgonera » 2016-11-04T01:50:18-07:00

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.

snibgo
Posts: 12286
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: convert svg weird result image

Post by snibgo » 2016-11-04T02:11:41-07:00

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.
snibgo's IM pages: im.snibgo.com

jgonera
Posts: 6
Joined: 2011-08-03T07:20:29-07:00
Authentication code: 8675308

Re: convert svg weird result image

Post by jgonera » 2016-11-04T02:19:42-07:00

Any way to validate an svg with imagemagick?

gringo974
Posts: 16
Joined: 2016-10-04T07:07:21-07:00
Authentication code: 1151

Re: convert svg weird result image

Post by gringo974 » 2016-11-04T08:17:29-07:00

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.

gringo974
Posts: 16
Joined: 2016-10-04T07:07:21-07:00
Authentication code: 1151

Re: convert svg weird result image

Post by gringo974 » 2016-11-04T08:40:02-07:00

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">).

Post Reply