如何更换PSD文件中的图层

问题描述:我用新的背景图像更换PSD文件中的背景图像,更换失败,代码和输入如下
输入背景图像:
1.jpg (138.0 KB)
替换后用PSD文件导出的图像为:
out_3_1.jpg (227.5 KB)
代码:
String path = “…/test_3.psd”;
String imgPath = “…/1.png”;
String desPath = “…/out_3_2.jpg”;

    Image image =Image.load(path);
    PsdImage psdImage = (PsdImage) image;

    String layerName = "图层 760";
    for(int i=0; i < psdImage.getLayers().length; i++ ) {
        String name = psdImage.getLayers()[i].getDisplayName();
        if (name.equals(layerName)) {
            SmartObjectLayer smartLayer = (SmartObjectLayer)psdImage.getLayers()[i];
            smartLayer.replaceContents(imgPath);
            smartLayer.updateModifiedContent();
        }
    }

    psdImage.save(desPath,new JpegOptions());

OS 版本:Windows 10 专业版
Aspose版本:23.4

如何用新的图像更换PSD文件某一图层中的图像呢,能给出具体例子吗?

psd文件地址: View Adobe® Photoshop® Files | PSD & PSB Viewer App

@junjun.pan 你能写下你有的例外吗?

我们已在内部问题跟踪系统中打开以下新票证,并将根据中提到的条款提供修复 Free Support Policies.

Issue ID(s): PSDJAVA-499

你可以获得 Paid Support Services 如果您需要优先支持,以及直接联系我们的付费支持管理团队。

请问下如何用现有图像更换PSD文件中某一图层中的图像?方便给个i例子吗

@junjun.pan we are actively working on new version of Aspose.PSD where this will be fixed. At this moment you can try create a new regular layer and then use RasterImage.LoadArgb32Pixels | Aspose.PSD for .NET API Reference and RasterImage.SaveArgb32Pixels | Aspose.PSD for .NET API Reference

Also, you can create new Layer from any format supported format like PSD, PNG, GIF, TIFF, JPEG, BMP.

Please check Pricing - Purchase - aspose.com there are plans with the paid support, Aspose Teams can implement specific tasks for your project.