你好,我是用的是试用版本的 aspose-psd-20.9-jdk16
需要实现的功能:替换智能图像
结果:图像是黑色的,在photoshop中选择智能图层-》更新所有,才能恢复正常
public void index() {
String sourceDir = GetDataDir_PSD();
PngOptions pngOptions = new PngOptions();
pngOptions.setColorType(PngColorType.TruecolorWithAlpha);
PsdImage image = (PsdImage) Image.load(sourceDir + "abc.psd");
try {
SmartObjectLayer smartObjectLayer = findLayerByName(image, "素材");
smartObjectLayer.replaceContents(sourceDir + "replace.png");
image.getSmartObjectProvider().updateAllModifiedContent();
image.save(sourceDir + "export.png", pngOptions);
image.save(sourceDir + "export.psd", new PsdOptions(image));
} catch (Exception e) {
System.out.println("ERROR:");
e.printStackTrace();
} finally {
image.dispose();
}
}
export.jpg (148.1 KB)