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

Free Support Forum - aspose.com

PSD to PNG , I got a error message when I load our psd file

aspose.zip (159.9 KB)

HI, I used the following code to covert our psd file to png.

using (System.IO.MemoryStream stream = new System.IO.MemoryStream())
{
try
{
using (PsdImage image = (PsdImage)Image.Load(@"./wwwroot/Psd/basic.psd"))
{

                    // Find Layer using layer's name
                    var layerToUpdateText = (TextLayer)FindLayer("headCopy", image);
                    // Simple way to update text
                    layerToUpdateText.UpdateText("Main Copy");
                    // Save the updated PSD file
                    image.Save(stream, new Aspose.PSD.ImageOptions.PngOptions());
                    return File(stream, "image/png");
                }
            }
            catch (Exception e)
            {
                _logger.Error(e.Message);
                return null;
            }
        }

But I got a message as blow.

"Image loading failed.
{“The type initializer for '\u0002 ’ threw an exception.”}

I dont know what problem is on my source.
Please let me know how I can fix this error.

Thanks.

@kains4 ,

I can confirm that this error is reproducible in the current Aspose.PSD version.
The investigation of InnerException showed that the problem is in the missing assembly ‘System.Text.Encoding.CodePages’.

To resolve this issue, try installing the ‘System.Text.Encoding.CodePages’ package into your project.

Let us know if that helped.