dongliuzhuan1219 2011-08-16 18:36
浏览 82

Image Magick没有将svg文件转换为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.

  • 写回答

2条回答 默认 最新

  • duan0530 2011-08-16 18:40
    关注

    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
    
    评论

报告相同问题?

悬赏问题

  • ¥15 #MATLAB仿真#车辆换道路径规划
  • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建
  • ¥15 数据可视化Python
  • ¥15 要给毕业设计添加扫码登录的功能!!有偿
  • ¥15 kafka 分区副本增加会导致消息丢失或者不可用吗?
  • ¥15 微信公众号自制会员卡没有收款渠道啊
  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘