如何替换图层,更新关联内容?

怎么替换图层图片实现自动更新?

var dataDir = AppDomain.CurrentDomain.BaseDirectory;
var psdFile = Path.Combine(dataDir, "test.psd");
var replaceImg = Path.Combine(dataDir, "test.png");
const string layerName = "插画-1-透明";
  
Console.WriteLine(dataDir);
Console.WriteLine(psdFile);
Console.WriteLine(replaceImg);

using var image = (PsdImage)Image.Load(psdFile);
  
var layerToReplaces1 = GetLayersByDisplayName<LayerGroup>(image, "Layer group: 替换");
foreach (var layerGroup in layerToReplaces1)
{
    Console.WriteLine($"SmartObjectLayer: {layerGroup.DisplayName}");
    foreach (var layer in layerGroup.Layers)
    {
        Console.WriteLine(layer.DisplayName);
        if (layer.DisplayName != layerName) continue;
        var smartObjectLayer = (SmartObjectLayer)layer;
        smartObjectLayer.ReplaceContents(replaceImg);
        smartObjectLayer.UpdateModifiedContent();
    }
}

image.SmartObjectProvider.UpdateAllModifiedContent();
image.Save(Path.Combine(dataDir, "test1.psd"), new PsdOptions(image));

var jpegOptions = new JpegOptions();
jpegOptions.Quality = 12;
jpegOptions.ColorType = JpegCompressionColorMode.Rgb;
image.Save(Path.Combine(dataDir, "test1.jpg"), jpegOptions);

问题:
我用代码无法实现和 Photo shop 一样的替换图层内容的效果,我该如何修改我的代码?

PSD File : PSD

下面是我要实现的效果
替换前 iShot_2024-11-06_12.55.00.jpg (674.9 KB)
替换后 iShot_2024-11-06_12.55.38.jpg (672.6 KB)

@karenboy
We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): PSDNET-2233

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.