How to keep the curves (photoshop transform) on the SmartObjectLayer?

Hi There,
I have a trouble with the conversion result from PSD that contains SmartObject into image(PSD, JPG, PNG) formats. My PSD file contains a layer is smartObject with transform on the picture I draw on it some curves. Here is the sample data Google Drive

  • Here is the structure of my PSD:
    image.jpg (313.0 KB)
  • I would like to replace the content of SmartObject layer by another picture and keep the curves… but I don’t know why the result something like not apply the transform/formatted:
    image.jpg (249.9 KB)
  • Then I try to open output.psd(above picture) and perform “Ctrl + T” => then result same as my expectation:
    image.jpg (225.7 KB)

So could you please show me what I need to export the PSD or PNG file contain the transform(the curves in my case for example). Here is my code:

public static void processPSD(string psdPath, string imagePath)
{
PsdLoadOptions options = new PsdLoadOptions() { LoadEffectsResource = true };
using (PsdImage psd = (PsdImage)Aspose.PSD.Image.Load(psdPath, options))
{
for (int i = 0; i < psd.Layers.Length; i++)
{
var layer = psd.Layers[i];
SmartObjectLayer smartObjectLayer = layer as SmartObjectLayer;
if (smartObjectLayer != null)
{
using (Stream stream = new FileStream(imagePath, FileMode.Open, FileAccess.Read))
{
smartObjectLayer.Contents = getByteValue(stream);
smartObjectLayer.UpdateModifiedContent();
psd.SmartObjectProvider.UpdateAllModifiedContent();
}
}
}
psd.Save(@“C:\Users\Cuong\Desktop\out-psd.psd”);
psd.Save(@“C:\Users\Cuong\Desktop\out-jpg.jpeg”, new JpegOptions() { ColorType= JpegCompressionColorMode.Rgb, CompressionType = Aspose.PSD.FileFormats.Jpeg.JpegCompressionMode.Baseline});
}
}

   public static byte[] getByteValue(System.IO.Stream stream)
   {
       long originalPosition = 0;

       if (stream.CanSeek)
       {
           originalPosition = stream.Position;
           stream.Position = 0;
       }

       try
       {
           byte[] readBuffer = new byte[4096];

           int totalBytesRead = 0;
           int bytesRead;

           while ((bytesRead = stream.Read(readBuffer, totalBytesRead, readBuffer.Length - totalBytesRead)) > 0)
           {
               totalBytesRead += bytesRead;

               if (totalBytesRead == readBuffer.Length)
               {
                   int nextByte = stream.ReadByte();
                   if (nextByte != -1)
                   {
                       byte[] temp = new byte[readBuffer.Length * 2];
                       Buffer.BlockCopy(readBuffer, 0, temp, 0, readBuffer.Length);
                       Buffer.SetByte(temp, totalBytesRead, (byte)nextByte);
                       readBuffer = temp;
                       totalBytesRead++;
                   }
               }
           }

           byte[] buffer = readBuffer;
           if (readBuffer.Length != totalBytesRead)
           {
               buffer = new byte[totalBytesRead];
               Buffer.BlockCopy(readBuffer, 0, buffer, 0, totalBytesRead);
           }
           return buffer;
       }
       finally
       {
           if (stream.CanSeek)
           {
               stream.Position = originalPosition;
           }
       }
   }

Note that I already research another method is smartObjectLayer.ReplaceContents("link_to_new_png_content.png"); but there NPE returns I don’t know why that, It happens when my SmartObjectLayer has transform curved.

Thank you for any suggestion.

@dvcuong05

After carefully observing the requirements, it seems to be missing support in API. However, I have created a ticket with ID PSDNET-893 in our issue tracking system as investigation to further investigate it and come up with any workaround or implementation to achieve the requirements. This thread has been linked with the issue so that you may be notified once the issue will be addressed.

1 Like

I have the same problem

@caacbb1

The associated issue is still unresolved. We will share feedback with you as soon as it will be fixed.

@dvcuong05
another way

  1. linked smart object
  2. change
  3. UpdateModifiedContent

@caacbb1

Please share the details of the issue in the form of sample example, source code, output obtained and desired output that you are referring to here.

PSDNET-893 is repair?

Have you achieved it?

@caacbb1

The issue PSDNET-893 is about how to keep the curves (photoshop transform) on the SmartObjectLayer. It’s not about repair. We will share feedback with you as soon as it will be fixed.

PSDNET-893 is finish?

@caacbb1

I regret to share that concerned issue is still unresolved. We request for your patience and will share the good news with you as soon as it will be fixed.

hello, PSDNET-893 is finish?

hello, PSDNET-893 is finish?

@caacbb1

I regret to share that at present the issue is unresolved. We request for your patience and will share feedback with you as soon as it will be fixed.

I also have this issue.

will work?..

I also have this issue.

@jokerOnlyOne this task is planned, but not implemented yet. We’ll increase priority of this task.