The Photoshop Document (PSD) is a well-known file format used by Adobe Photoshop for saving the data in the form of layers. The layers are combined together to obtain the desired artwork or images. Adobe Photoshop allows the designers to export the PSD layers as a single image in the form of PNG, JPG, GIF, TIFF, and other formats.
In case you want to implement the feature of converting or exporting the PSD files to raster image formats without Photoshop, you will definitely look for some automation. For such a case, I am going to demonstrate how to convert PSD to PDF, JPG, PNG, BMP or other raster image formats programmatically using C#. Furthermore, you’ll also learn how to convert or export the desired layer/layer group in the PSD. This article covers the following PSD conversions in C#:
- PSD to JPG
- PSD to PNG
- PSD to BMP
- PSD to TIFF
- PSD to GIF
- PSD to JP2
- PSD to PDF
- PSD layer/layer group to image
C# PSD Converter API - Aspose.PSD for .NET
For converting PSD to PDF and image formats, we’ll leverage the capabilities of Aspose.PSD for .NET which is simple and easy to use .NET API for manipulation and conversion of Photoshop files (PSD). In addition to conversion features, the API also lets you create and edit the Photoshop PSD files, update layer properties, insert watermarks, and perform various graphics-related operations on PSD files. Aspose.PSD for .NET can be installed from NuGet as well as downloaded as DLL from the Downloads section.
Convert PSD to JPG in C#
The following are the steps to convert a PSD file to JPG image in C#:
- Create an object of the Image class and initialize it with the PSD file’s path.
- Create an object of the JpegOptions class.
- Convert PSD to JPG using Image.Save(string, JpegOptions) method.
The following code sample shows how to convert a PSD file to JPG in C#:
PSD File
Converted JPG Image
Convert PSD to PNG in C#
The following are the steps to convert a PSD file to PNG image in C#:
- Create an object of the Image class and initialize it with the PSD file’s path.
- Create an object of the PngOptions class.
- Convert PSD to PNG using Image.Save(string, PngOptions) method.
The following code sample shows how to convert a PSD file to PNG in C#:
Convert PSD to BMP in C#
The following are the steps to convert a PSD file to BMP image in C#:
- Create an object of the Image class and initialize it with the PSD file’s path.
- Create an object of the BmpOptions class.
- Convert PSD to BMP using Image.Save(string, BmpOptions) method.
The following code sample shows how to convert a PSD file to BMP in C#:
Convert PSD to TIFF in C#
The following are the steps to convert a PSD file to TIFF image in C#:
- Create an object of the Image class and initialize it with the PSD file’s path.
- Create an object of the TiffOptions class.
- Convert PSD to TIFF using Image.Save(string, TiffOptions) method.
The following code sample shows how to convert a PSD file to TIFF in C#:
Convert PSD to GIF in C#
The following are the steps to convert a PSD file to GIF image in C#:
- Create an object of the Image class and initialize it with the PSD file’s path.
- Create an object of the GifOptions class.
- Convert PSD to GIF using Image.Save(string, GifOptions) method.
The following code sample converts a PSD file to GIF in C#:
Convert PSD to JP2 in C#
The following are the steps to convert a PSD file to JP2 image in C#:
- Create an object of the Image class and initialize it with the PSD file’s path.
- Create an object of the Jpeg2000Options class.
- Convert PSD to JP2 using Image.Save(string, Jpeg2000Options) method.
The following code sample converts a PSD file to JP2 in C#:
Convert PSD to PDF in C#
The following are the steps to convert a PSD file to PDF document in C#:
- Create an object of the Image class and initialize it with the PSD file’s path.
- Create an object of the PdfOptions class.
- Convert PSD to PDF document using Image.Save(string, PdfOptions) method.
The following code sample converts a PSD file to PDF document in C#:
Convert a Layer or Layer Group of PSD in C#
You can also convert a particular layer or layer group in the PSD file to raster image formats (JPG, PNG, etc.). The following are the steps to perform this operation.
- Create an object of the PsdImage class and load the PSD file.
- Access the layer or layer group using PsdImage.Layers array.
- Render the layer as an image.
The following code sample shows how to convert a layer group of PSD to PNG in C#.
Learn more about Aspose.PSD for .NET
You can explore more about the Aspose.PSD for .NET using the documentation.