Free Support Forum - aspose.com

Smart object

Hello, is there any example code for Java operating smart objects? I just tried to replace the content of the smart object, but there seems to be a file corruption.

String path = dataDir + “/psd/smartObject.psd”;
PsdImage psdImage = (PsdImage) PsdImage.load(path);
String replacePath = dataDir + “/psd/demo.psd”;
for (Layer layer : psdImage.getLayers()) {
if (layer instanceof SmartObjectLayer) {
SmartObjectLayer smartObjectLayer = (SmartObjectLayer) layer;
if (“asd”.equals(smartObjectLayer.getDisplayName())){
smartObjectLayer.replaceContents(replacePath);
smartObjectLayer.updateModifiedContent();
}
}

    }
    psdImage.save(path);

@1395759132

Please share the source file along with generated output with us so that we may try to reproduce the issue on our end. Please also share the API version, Java and Operating system details as well.

Java version 1.8.0_281
API version 20.9
windows_64 cpu Inter i5-10400f
https://yuqingchenag.oss-cn-shenzhen.aliyuncs.com/demo.psd
https://yuqingchenag.oss-cn-shenzhen.aliyuncs.com/smartObject.psd

I would like to ask why there is no information about the SmartObjectLayer class in the api document. What are the requirements for the parameters of the replaceContents method of this class?

@1395759132

At present, we haven’t yet added support for Smart Objects on Aspose.PSD For Java. We working on release where these features are available, but planned date of this release is end of May. We request for your patience and suggest you to please try the new release when it will be available.

thank you for your answer

@1395759132

You are always welcome.