Free Support Forum - aspose.com

HOW to import an image AS smartobjectLayer

Hi, I try to import an image to PSD, it’s successful, but
is a normal Layer, how to be a smartobjectLayer.
Thank you all for your guidance.
code following:

using (var image = (PsdImage)Aspose.PSD.Image.Load(@"C:\001.psd"))
{

            string filePath = @"C:\test.jpg";
            using (var stream = new FileStream(filePath, FileMode.Open))
            {
                Layer layer = null;
                try
                {
                    layer = new Layer(stream);
                    image.AddLayer(layer); 
                }
                catch (Exception e2)
                {
                    if (layer != null)
                    {
                        layer.Dispose();
                    }
                    throw e2;
                }
            }

            image.Save(@"C:\003.psd");
        }

@Tim_Pan

I suggest you to please refer to following thread for your convenience.

Hi, Yes, I have read this article before.
I hope that the layer will be converted to a smart object layer and saved as a PSD. When using Adobe Photoshop open it is still a smart object layer.
I tried the new code and Run was successful and save PSD successful , but the output PSD cannot Open with Adobe Photoshop,Thank you.


        using (PsdImage image = (PsdImage)Image.Load(@"C:\test1.psd"))
        {


            image.SmartObjectProvider.ConvertToSmartObject(1);
            //Layers[1] convert to smart object layer

            image.Save(@"C:\test1ok.psd", new PsdOptions(image));

            image.Dispose();


        }

@Tim_Pan

Can you please share the source file, generated file and snapshot of PSD failing to get opened in Photoshop along with Photoshop version.

HI
My VS 2019 C# Project
PSDtest.Zip
When Adobe Photoshop open layerTest3.psd REEOR 506086.jpg (149.5 KB)

I expect the result of opening with Photoshop My expected result.jpg (296.1 KB)

Thank you

@Tim_Pan

I have created a ticket with ID PSDNET-790 in our issue tracking system to further investigate and resolve the issue. This thread has been linked with the issue so that you may be notified once the issue will be fixed.