0

I'm a beginner at using ImageMagick. I have a simple svg image from the file system, and I want to convert it to png file, so I ran:

$ convert -resize 100% ~/image.svg ~/image.png

And the error is:

convert-im6.q16: non-conforming drawing primitive definition `px' @ error/draw.c/DrawImage/3265.

My image.svg:

<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg" style="width: 100%; height: 100%; cursor: grab;" viewBox="-490 -155 1311 669">
    <g stroke="#000" class="item" style="stroke-width: 3px; stroke-linecap: round;">
        <rect x="273" y="149" width="126" height="111" stroke="transparent" fill="none" style="stroke-width: 30px;"></rect>
        <rect x="273" y="149" width="126" height="111" fill="none"></rect>
    </g>
    <g stroke="#000" class="item" style="stroke-width: 3px; stroke-linecap: round;">
        <ellipse cx="-167.5" cy="97.5" rx="209.5" ry="206.5" stroke="transparent" fill="none" style="stroke-dasharray: 5px, 5px; stroke-width: 30px;"></ellipse>
        <ellipse cx="-167.5" cy="97.5" rx="209.5" ry="206.5" fill="none"></ellipse>
    </g>
</svg>

My ImageMagick version:

Version: ImageMagick 6.9.7-4 Q16 x86_64 20170114 http://www.imagemagick.org                                                                                                                       
Copyright: © 1999-2017 ImageMagick Studio LLC                                                                                                                                                     
License: http://www.imagemagick.org/script/license.php                                                                                                                                            
Features: Cipher DPC Modules OpenMP                                                                                                                                                               
Delegates (built-in): bzlib djvu fftw fontconfig freetype jbig jng jpeg lcms lqr ltdl lzma openexr pangocairo png tiff wmf x xml zlib

My rsvg-convert version:

rsvg-convert version 2.40.20
Jasper Martin
  • 180
  • 3
  • 11
  • What's the svg file you're trying to convert? Remove things from it till you've got a minimal example that shows the problem. Then edit the question to include that minimal file. – Robert Longson Aug 12 '19 at 06:45
  • Oh yeah, sorry about that @RobertLongson – Jasper Martin Aug 12 '19 at 06:56
  • There are various things with px units, which of them cause the problem? You can find out by removing the properties till you find out. Do you need both elements and their contents or will just one do? – Robert Longson Aug 12 '19 at 08:35

1 Answers1

1

I ran the following command fine on IM 6.9.10.60 Q16 Mac OSX where ImageMagick is using Inkscape to do the rendering. It also worked using IM 6.9.7.4 with RSVG 2.44.13_0.

convert test.svg test.png

and also

convert test.svg -resize 100% test.png


enter image description here

Your syntax is not correct for ImageMagick. You should read the svg file or any input image before doing -resize.

You can try to upgrade to the latest RSVG. You are several versions behind.

Or install Inkscape and ImageMagick will use it in preference to either RSVG or ImageMagick MSVG/XML internal renderer.

fmw42
  • 46,825
  • 10
  • 62
  • 80