How do I modify the content of a Smart Object?

My psd file has an artboard, and there is a smart object in the artboard. I want to open the smart object and drag in the picture and save it like in photoshop. I don’t know how to modify the content in the smart object, and it always gives an error. Another question is, will Image.load give an error when loading a picture?

@houdajin

Can you please provide more details about the error you are encountering when trying to modify the content of the Smart Object?

String materialPath = “ZNDX.psd”;
PsdImage materImage = (PsdImage) Image.load(materialPath);
// 遍历图层并找到目标图层
String filePath = “TRF6241.png”;
FileStream stream = new FileStream(filePath, FileMode.Open);
SmartObjectLayer layerNew = null;
layerNew = new SmartObjectLayer(stream);
Layer[] layers = materImage.getLayers();
layers[0] = layerNew;
materImage.setLayers(layers);
// 保存修改后的 PSD 文件
String outputPsdPath = “output.psd”;
materImage.save(outputPsdPath);
materImage.dispose();

@houdajin could you please provide file that you are trying to process. Aspose.PSD team will check it.