PSD Image Converter for .NET

Introduction to PSD Image Converter for .NET

The PSD Image Converter for .NET is a powerful plugin that allows developers to convert PSD image files to various other formats. This guide provides an overview of the available features and explains how to perform common tasks using code examples in .NET.

Converting PSD Images

The PSD Image Converter for .NET supports conversion of PSD images to several popular formats, including JPEG, PNG, GIF, BMP, and TIFF. The following code example demonstrates how to convert a PSD image to a JPEG file:

using (PsdImage psdImage = (PsdImage)Image.Load("input.psd"))
{
    PsdOptions psdOptions = new PsdOptions();
    psdOptions.ColorMode = ColorModes.Rgb;

    JpegOptions jpegOptions = new JpegOptions();
    jpegOptions.CompressionType = JpegCompressionMode.BaseLine;

    psdImage.Save("output.jpg", jpegOptions);
}

Supported Conversion Formats

The PSD Image Converter for .NET supports the following conversion formats:

  • JPEG
  • PNG
  • GIF
  • BMP
  • TIFF

Each format has its own set of options that can be used to customize the conversion process. For example, when converting to JPEG, you can specify the compression type and quality.

Customizing Conversion Options

The PSD Image Converter for .NET provides a range of options for customizing the conversion process. These options include:

  • Color mode: Specify the color mode of the output image (e.g. RGB, CMYK)
  • Channel bits: Specify the number of bits per channel (e.g. 8, 16)
  • PSD version: Specify the version of the PSD file (e.g. PSD2, PSD3)

The following code example demonstrates how to customize the conversion options when converting a PSD image to a PNG file:

using (PsdImage psdImage = (PsdImage)Image.Load("input.psd"))
{
    PsdOptions psdOptions = new PsdOptions();
    psdOptions.ColorMode = ColorModes.Rgb;
    psdOptions.ChannelBits = 8;
    psdOptions.PsdVersion = PSDVersion.PSD2;

    PngOptions pngOptions = new PngOptions();
    pngOptions.CompressionLevel = CompressionLevel.Type9;

    psdImage.Save("output.png", pngOptions);
}

Loading and Saving Images

The PSD Image Converter for .NET supports loading and saving images from various sources, including files, streams, and byte arrays. The following code example demonstrates how to load a PSD image from a file and save it as a JPEG file:

using (PsdImage psdImage = (PsdImage)Image.Load("input.psd"))
{
    JpegOptions jpegOptions = new JpegOptions();
    jpegOptions.CompressionType = JpegCompressionMode.BaseLine;

    psdImage.Save("output.jpg", jpegOptions);
}

Error Handling

The PSD Image Converter for .NET provides robust error handling mechanisms to ensure that your application remains stable and reliable. The following code example demonstrates how to handle errors when converting a PSD image:

try
{
    using (PsdImage psdImage = (PsdImage)Image.Load("input.psd"))
    {
        JpegOptions jpegOptions = new JpegOptions();
        psdImage.Save("output.jpg", jpegOptions);
    }
}
catch (ImageSaveException ex)
{
    Console.WriteLine("Error converting PSD image: " + ex.Message);
}
 English