Page 1 of 1

Problem with SVG pattern

Posted: 2018-10-13T11:32:09-07:00
by fedushok
Hello

I use ImageMagick-6.9.3-7-vc14-x86 (php_imagick-3.4.3-7.1-ts-vc14-x86). My task is to create SVG and to convert it to PNG. Some of my objects have hatch. It is rendered correctly in Inkscape but in PNG it is not present. Hatch lines are black and if I set not black but even #000001 hatch appears. How to make it work with black?
Here is simple example

Code: Select all

<svg width="34" height="37" stroke="#000000" stroke-width="1px" version="1.1" xmlns="http://www.w3.org/2000/svg">
 <g id="bcsGroup" transform="translate(-38,-172)">
  <g transform="translate(55,181)" stroke="#000" data-n="1" data-t="c">
   <line y2="17"/>
   <circle r="3.5" fill="#fff"/>
   <line x1="-12" x2="12" y1="17" y2="17"/>
   <defs>
    <pattern id="oneDCGround1" x="-4" width="6" height="6" patternUnits="userSpaceOnUse">
     <line x2="6" y1="6"/>
    </pattern>
   </defs>
   <rect x="-12" y="17" width="24" height="6" fill="url(#oneDCGround1)" stroke="none"/>
   <circle cy="17" r="3.5" fill="#fff"/>
  </g>
 </g>
</svg>
Here is correct result
Image

Re: Problem with SVG pattern

Posted: 2018-10-13T12:05:07-07:00
by fmw42
Your Imagemsgick 6.9.3.7 is rather old. You might want to upgrade. Imagemagick is now at 6.9.10.12. Imagemagick can render SVG files with different tools. It has its own MSVG/XML renderer. It can use the RSVG delegate if installed and it can use Inkscape if that is on your system and you are using a current enough version of Imagemagick. You can see which is being use (MSVG/XML or RSVG), from convert -list format. Or by adding -verbose to your convert command.

Generally speaking inkscape is best, then RSVG, then MSVG. But MSVG has been improved lately. I test all 3 and MSVG was best, inkscape was next, but the dashed lines were a bit blurry and RSVG dropped your dashed line. Here are my results

Inkscape:
Image

RSVG:
Image


MSVG:
Image




I tested with IM 6.9.10.12 Mac OSX Sierra for MSVG and with librsvg @2.42.2_2 and inkscape @0.92.3_4. Also I used libpng @1.6.35_0.

I think you need to check what renderer you are using and possibly update it or change to one of the others and also be sure you are using a current version of libpng.

Re: Problem with SVG pattern

Posted: 2018-10-13T23:48:28-07:00
by fedushok
Thank you for your informative reply