Problem on converting svg to png

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
abreu

Problem on converting svg to png

Post by abreu »

Hi. First of all let me thank the developers for the great piece of software that is ImageMagick. It is very useful.

I'm having a problem converting this svg:

Code: Select all

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
   xmlns:svg="http://www.w3.org/2000/svg"
   xmlns="http://www.w3.org/2000/svg"
   version="1.0">
	<polygon
		points="0,0.283454 3.18392,0.468029 6.53593,0 7.20171,0.784443 9.01121,0.715227 9.88794,2.52802 9.29136,2.96638 9.29136,4.48253 9.88794,4.9209 9.01121,6.73368 7.20171,6.66447 6.53593,7.44891 3.18392,6.98088 0,7.16546"
		style="opacity:1;fill:#b3b3b3;fill-opacity:1;fill-rule:evenodd;stroke:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"/>
</svg>
The generated png is cropped at the bottom. However several polygons are correct which is strange because they are all generated with the same command:

convert -density 3000 piece0.svg piece0.png

I also tried rsvg with -width and -height instead of -density and the result was the same.

Any ideas?
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Problem on converting svg to png

Post by anthony »

The above converts fine with...

Code: Select all

convert -density 3000 -size 10x10 msvg:polygon.svg x:
Though the rsvg code seems to have more problems as one point seems to be missing from its output. I don't think the SVG is quite complete as IM complains of a missing 'size' if that option is not provided. Normally the size will be set within the SVG somewhere.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
abreu

Re: Problem on converting svg to png

Post by abreu »

I solved my issue by increasing the size of the polygons. The pngs were perfect and sharper (although slower conversion). I usually dont include "size" on the SVGs, I thought the polygon points were enough since they displayed correctly (most of them).
Now Im looking into <animateMotion> :) . Thanks for the answer.
Post Reply