Free Support Forum - aspose.com

Need to load Jpeg to psd layer through C#

Hi, I need to replace a layer in psd file with local jpeg. But I don’t see any available methods to do so in MVC (.NET). Kindly assist.

P.S: Below is the code to create a new rectangle with yellow color. Instead I need to use my own local image to replace a layer.
// Create an image that is needed to be imported into the PSD file.
using (PsdImage drawImage = new PsdImage(layer.Width, layer.Height))
{
// Fill image surface as needed.
Graphics g = new Graphics(drawImage);
g.Clear(Color.Yellow);

                // Call DrawImage method of the Layer class and pass the image instance.
                layer.DrawImage(new Point(0, 0), drawImage);
            }

@lifegoeson,

I have observed the requirements shared by you and like to share that we are working over it and will get back to you with feedback as soon as possible.

Thank you. Looking forward to hearing from you.

@lifegoeson,

Sure, we will share updates with you as soon as possible.

@lifegoeson,

I suggest you to please access the particular layer in Graphics object rather loading the entire PSD image. Can you please consider using following alternate on your end. You can also check this documentation link for your kind reference as well.

   var g = new Graphics(layer);
   g.Clear(Color.Green);
   g.DrawImage(newLayer, new Rectangle(new Point(), new Size(width, height)));

Hello Mr. Mudassir, Thank you for responding, I have tried the suggested solution by you. But I didn’t find any method to export local “JPG” file to psd. When I tried to create image using below line of code it throws error. So kindly assist.

PsdImage image = (PsdImage)Image.Load(@“C:\Users\Toshiba\Desktop\Testpsd\Bed Room.jpg”)

@lifegoeson,

I have observed the sample code. Your sample code is wrong here. You are loading a JPEG with PsdImage class object, which is wrong.

That was my question, how to upload JPEG file to psd layer. Kindly assist

@lifegoeson,

We are working over this requirement and will get back to you with feedback as soon as possible.

@lifegoeson,

I suggest you to please visit this documentation link for your kind reference.