开发者

SVG to PNG by PythonMagickWand

开发者 https://www.devze.com 2023-01-24 05:31 出处:网络
I try to convert SVG to PNG. Result picture has a white background I need transparent. Sample of code:

I try to convert SVG to PNG. Result picture has a white background I need transparent.

Sample of code:

wand = NewMagickWand()
MagickReadImage(wand,tmp_file_name)
transparentColor = NewPixelWand()
PixelSetMagickColor(transparentColor, 'none')
MagickSetBackgroundColor(wand, transparen开发者_运维百科tColor)
MagickWriteImage(wand,new_filename)

if I do in command-line:

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

I've got a transparent picture.


I used subprocess and I got what I want

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

精彩评论

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