SmartObject ReplaceContents have problem with reRender

Hello,
I have a problem when using the ReplaceContents function, after I ReplaceContents, PSD result file it did not work as I expected.

  1. Using Photoshop CC 2018
    This is my PSD file ([Render.psd GoogleDrive](https://drive.google.com/file/d/1crKWaqe2x5iRrb4iCG6_lTQ2zx7lR8a7/view?usp=sharing))
    image.jpg (347.3 KB)
    I’m using photoshop cc 2018 and right click on SmartObject sleeves hoodie upload and choose Replace Contents then select new sleeves image file (sleeves hoodie.jpg (511.7 KB))
    .
    This is result:
    image.jpg (331.7 KB)
    This is the right result I expected
  2. Using ASPOSE.PSD dot Net
    This is my code:
namespace PSD
{
    class Program
    {
        static void Main(string[] args)
        {
            using (PsdImage image = (PsdImage)Image.Load(“render.psd”))
            {

                foreach (var layer in image.Layers)
                {
                    Console.WriteLine("Layer: {0}", layer.DisplayName);
                }
                var smartObjectLayer = (SmartObjectLayer)FindLayer("sleeves hoodie upload", image);

                using (var img = new PsdImage(5000, 3600))
                {
                    using (Stream stream = new FileStream(@"sleeves hoodie.jpg", FileMode.Open))
                    {
                        Layer layer = null;
                        try
                        {
                            layer = new Layer(stream);
                            img.AddLayer(layer);
                        }
                        catch (Exception e)
                        {
                            if (layer != null)
                            {
                                layer.Dispose();
                            }
                            throw e;
                        }
                        smartObjectLayer.ReplaceContents(img);
                        Console.WriteLine("Replace contents");
                    }
                }
                image.SmartObjectProvider.UpdateAllModifiedContent();
                image.Save("ouput_hoodie.psd", new PsdOptions(image));
                Console.WriteLine("Press enter to close...");
                Console.ReadLine();
            }
            Layer FindLayer(string layerName, PsdImage image)
            {
                // Get aa layers in PSD file
                var layers = image.Layers;
                // Find desired layer
                foreach (var layer in layers)
                {
                    // Match layer's name
                    if (string.Equals(layer.DisplayName, layerName, StringComparison.InvariantCultureIgnoreCase))
                    {
                        return layer;
                    }
                }
                return null;
            }
        }
    }
}

And this is result when I run code
image.jpg (345.1 KB)
[ouput_hoodie.psd (Google drive link)]
Files to test:
sleeves hoodie.jpg (511.7 KB)
[Render.psd (Google Drive Link)](https://drive.google.com/file/d/1crKWaqe2x5iRrb4iCG6_lTQ2zx7lR8a7/view?usp=sharing)

Thank you for reading and support.

@huunhat07

I have verified the images shared by you and we need to investigate this further on our end. A ticket with ID PSDNET-769 has been created in our issue tracking system to further investigate and resolve the issue. This thread has been linked wit the issue so that you may be notified once the issue will be fixed.

1 Like

Hello! Any update for this problem? I got same problem.

@senprints we make additional investigation of this task. Two years ago we hadn’t ability to fix it. In the last release 23.2 we implement PSDNET-1270: Add ability to process Warp Effect though the public API.

Please try the to use var warpLoadOptions = new PsdLoadOptions() { AllowWarpRepaint = true }; on the loading.

string sourceFile = "source.psd";
string pngWarpedExport = "warped.png";
string psdWarpedExport = "warpFile.psd";

var warpLoadOptions = new PsdLoadOptions() { AllowWarpRepaint = true };

using (var image = (PsdImage)Image.Load(sourceFile, warpLoadOptions))
{
    image.Save(pngWarpedExport, new PngOptions());
    image.Save(psdWarpedExport, new PsdOptions());
}

After the investigation by Dev Team, I’ll write you back.

It not working.
image.png (11.8 KB)
After use “AllowWarpRepaint” got exception after 2 minutes.
image.png (9.9 KB)

Without “AllowWrapRepaint”
image.jpg (71.7 KB)

We bought license for use “ReplaceContent” func, but it not work. When you guys fix this?

@senprints could you please provide input file and the code you use to replace contents.

ReplaceContent method: https://gist.githubusercontent.com/leakedby/0266752df0f7bcef2c909b182a538ed8/raw/f10332a90c0f3639ae109e98c638b6c695ae0be8/replace.cs

Mug PSD and artwork files: https://mega.nz/folder/SZhm2aaC#bl-yZdzMgWKHWv3WnaBirQ

@Dmitriy.Sorokin

Please help :smiley:

@senprints I created task PSDNET-1505: SmartObject ReplaceContents (when the AllowWarpRepaint options is active) falls after 2 minutes of computing

It will be investigated and fixed with high priority

Thank you, any update for this task? My deadline is coming soon :laughing:

@senprints the issue wil be released in 23.4-23.5, it has high priority.

The issues you have found earlier (filed as PSDNET-1505) have been fixed in this update. This message was posted using Bugs notification tool by yaroslav.lisovskyi