PythonMagickWand的SVG到PNG

时间:2010-11-10 21:23:36

标签: magickwand

我尝试将SVG转换为PNG。结果图片有白色背景我需要透明。

代码示例:

wand = NewMagickWand()
MagickReadImage(wand,tmp_file_name)
transparentColor = NewPixelWand()
PixelSetMagickColor(transparentColor, 'none')
MagickSetBackgroundColor(wand, transparentColor)
MagickWriteImage(wand,new_filename)

如果我在命令行中执行:

convert -background 'transparent' ./media/2222222.svg ./media/2222222.png

我有一张透明的照片。

1 个答案:

答案 0 :(得分:2)

我使用了子进程,我得到了我想要的东西

args = ['convert', '-background', 'transparent', './media/2222222.svg', './media/2222222.png',]
result = subprocess.call(args)