We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

'Image' does not contain a definition for 'Load'

this is the code i use

using Aspose.PSD.FileFormats.Psd;
using Aspose.PSD.FileFormats.Psd.Layers;
using Aspose.PSD.FileFormats.Psd.Layers.Text;

namespace Dowodzik
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

	//-------------------FindLayer()-------------
	public static 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;
	}


	private void button1_Click(object sender, EventArgs e)
    {
		// Load PSD file
		using (PsdImage image = (PsdImage)Image.Load(@"template.psd"))
		{
			// Find Layer using layer's name
			var layerToUpdateText = (TextLayer)FindLayer("Name", image);
			// Simple way to update text
			layerToUpdateText.UpdateText("John Doe");
			// Save the updated PSD file
			image.Save("updated-psd.psd");
		}
	}
}

}

@VVSES could you please provide the “template.psd” file for the investigation of the issue. You can attach this file to post, only the admins can download the attachments.

i dont have the file yet maybe thats why. also what should Image.Load refer to?

@VVSES please check the following documentation: https://docs.aspose.com/psd/net/installation/
You need to install Aspose.PSD from Nuget package manager, or download it from this page https://releases.aspose.com/psd/net/

Then all should work fine.

i did install it i typed

using Aspose.PSD.FileFormats.Psd;
using Aspose.PSD.FileFormats.Psd.Layers;
using Aspose.PSD.FileFormats.Psd.Layers.Text;

and it still shows ‘Image’ does not contain a definition for ‘Load’

Please try to change the code “Image.Load” to “Aspose.PSD.Image.Load”

// Load PSD file
		using (PsdImage image = (PsdImage)Aspose.PSD.Image.Load(@"template.psd"))
		{
			// Find Layer using layer's name
			var layerToUpdateText = (TextLayer)FindLayer("Name", image);
			// Simple way to update text
			layerToUpdateText.UpdateText("John Doe");
			// Save the updated PSD file
			image.Save("updated-psd.psd");
		}