简体   繁体   English

im4java将svg转换为png,保持透明背景

[英]im4java Convert svg to png, keep transparent background

I'm using the im4java library to convert svg files to png files. 我正在使用im4java库将svg文件转换为png文件。 I want the transparent backgrounds to remain transparent but they always become white. 我希望透明背景保持透明,但它们始终变为白色。 This is the operation I'm using: 这是我正在使用的操作:

IMOperation hdpiOperation = new IMOperation();
hdpiOperation.addImage();
hdpiOperation.background("none");
hdpiOperation.addImage();

If I manually try with ImageMagick from the commandline using this command it does work: 如果我使用此命令从命令行手动尝试使用ImageMagick,它将起作用:

convert -background none a.svg b.png

Any ideas? 有任何想法吗?

Since im4java appends parameters in method execution order, you can move hdpiOperation.background("none") call before image placeholders to mimic working 'raw' command: 由于im4java会按方法执行顺序附加参数,因此可以在图像占位符之前移动hdpiOperation.background("none")调用以模仿有效的“ raw”命令:

hdpiOperation.background("none");
hdpiOperation.addImage();
hdpiOperation.addImage();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM