开发者

Image Magick not converting svg file to jpg

I am using Image Magick library to convert a .svg file into a jpg but it is creating a blank image. I have checked a lot of forums for it , but was not able to figure out the problem with it. I have a file name abc.svg , which have the following code inside it;

<?xml version="1.0"?>
<svg xmlns="http://www.w3.org/2000/svg" width="12cm" height="12cm">
<g style="fill-opacity:0.7; stroke:black; stroke-width:0.1cm;">
<circle cx="6cm" cy="2cm" r="100" style="fill:red;"transform="translate(0,50)" /> 
<circle cx="6cm" cy="2cm" r="100" style="fill:blue;"transform="translate(70,150)" />
<circle cx="6cm" cy="2cm" r="100" style="fill:green;"transform="translate(-70,150)"/>
 </g>
</svg>

I am trying to convert it by the following command :

$convert abc.svg abc.jpg

But the file I am getting (i.e abc.jpg is 开发者_开发问答simply blank)

Please help me out with the problem, so that I can move ahead with the thing.

Thanks in advance.


This is possibly because JPEG does not support transparency, and is misinterpreting the SVG opacity. According to this post on the ImageMagick forums, you could try to first flatten the SVG with a background color and then convert it to JPEG.

convert image.svg  -background gray  -flatten  output.jpg
convert abc.svg abc.jpg


For one thing, your SVG file has errors. You are missing a space before the transform attribute in your three circles. It converts fine for me with ImageMagick (6.6.9-7 from Debian) after I fix that.

But when I try your file in ImageMagick, it doesn't give me an empty file. It gives a few errors and no output file at all. Does your SVG file work in any other program, e.g. Inkscape? Does your copy of ImageMagick handle other SVG files?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜