Convert PSD to PNG in C#

PSD (Photoshop Document) is a native image file format for Adobe Photoshop. PSD files are commonly used to create logos, brochures, and other images. Designers can export Photoshop layers as PNG images in Adobe Photoshop. We can programmatically convert or export PSD files to PNG images without Photoshop. In this article, we will learn how to convert a PSD to a PNG in C#.

The following topics shall be covered in this article:

  1. C# PSD to PNG Converter API
  2. Steps to Convert PSD to PNG
  3. Convert PSD to PNG using C#

C# PSD to PNG Converter API

For converting PSD files to PNG images, we will be using the Aspose.PSD for .NET API. The API allows manipulating Adobe Photoshop file formats easily. It also allows .NET applications to load and read PSD and PSB files. It is possible to update layer properties, add watermarks, rotate, scale, render, and convert PSD and a number of other supported file formats without having to install Adobe Photoshop.  

The Image class of the API is the base class for all type of images. The PsdImage class of the API allows loading, editing, and saving PSD files. It provides the Save(string, ImageOptionsBase) method that saves the PSD to the specified file location in the specified file format according to save options. The API provides the PsdLoadOptions class to specify PSD load options. The PngOptions class provides the PNG file format create options.

Please either download the DLL of the API or install it using NuGet.

PM> Install-Package Aspose.PSD

How to Convert PSD to PNG

We can easily convert any PSD file to a PNG image format by following the steps given below:

  • Define PSD load options.
  • Load a PSD file.
  • Specify PNG save options.
  • Save PSD as a PNG.

The following section describes how to transform these steps into C# code and export a PSD file to a PNG format.

Convert PSD to PNG using C#

We can convert PSD files to PNG images by following the steps given below:

  1. Firstly, create an instance of the PsdLoadOptions class.
  2. Then, specify load options such as ReadOnlyMode.
  3. Next, load a PSD file as PsdImage using the Image class.
  4. Then, initialize the PngOptions class object.
  5. After that, specify PNG options such as ColorType, Progressive, CompressionLevel, etc.
  6. Finally, save the output file using the Save() method.

The following code sample shows how to convert a PSD to a PNG in C#.

Source PSD

Source PSD

Convert PSD to PNG using C#

Converted PNG

Get Free Temporary License

You can get a free temporary license to try Aspose.PSD for .NET without evaluation limitations.

Conclusion

In this article, we have learned how to:

  • load an existing PSD file;
  • specify PSD load and PNG options;
  • save PSD as a PNG using C#.

Besides converting PSD to PNG in C#, you can learn more about Aspose.PSD for .NET using documentation and explore different features supported by the API. In case of any ambiguity, please feel free to contact us on our free support forum.

See Also