我需要将PNG转换为JPG。
但是,iMagick会给它添加黑色背景。
我看到了这个问题,它是关于PHP的,我尝试像这样为Java编写相同的内容:
// create the a jpg image
ConvertCmd cmd = new ConvertCmd();
// create the operation, add images and operators/options
IMOperation op = new IMOperation();
op.addImage(brandingURL);
op.format("JPEG");
op.composite();
op.background("white");
op.addImage(imageLocation);
//op.transparent();
// execute the operation
cmd.run(op);
但是,图片仍然带有黑色背景。我错过了什么吗?
draw
命令),但使用普通的Java图像io,您可以创建一个BufferedImage
,并使用相关的Graphics
对象来填充背景并在其上绘制PNG。 - Thomasjavax.imageio.ImageIO
吗? - Samuel Audet