我尝试将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
我有一张透明的照片。
我使用子流程,我得到了我想要的
args = ['convert', '-background', 'transparent', './media/2222222.svg', './media/2222222.png',] result = subprocess.call(args)