PSD Photo Processor for .NET
Introduction to PSD Photo Processor for .NET
The PSD Photo Processor for .NET is a powerful library that allows developers to process and manipulate Photoshop files (PSD) in their .NET applications. This guide provides an overview of the available features and explains how to accomplish common tasks using code examples.
Loading and Saving PSD Files
To start working with PSD files, you need to load them into your application. The PSD Photo Processor for .NET provides a simple way to do this:
using (PsdImage image = (PsdImage)Image.Load("input.psd", new PsdLoadOptions() { LoadEffectsResource = true }))
{
// Process the image
image.Save("output.psd");
}
In this example, we load a PSD file named “input.psd” and save it as “output.psd”.
Image Processing Operations
The PSD Photo Processor for .NET supports various image processing operations, including:
Resizing Images
To resize an image, you can use the Resize
method:
string sourceFile = dataDir + @"sample.psd";
string destName = dataDir + @"SimpleResizing_out.jpg";
// Load an existing image into an instance of RasterImage class
using (Image image = Image.Load(sourceFile))
{
image.Resize(800, 600);
image.Save(destName, new JpegOptions());
}
This code resizes the image to 800x600 pixels.
Rotating Images
To rotate an image, you can use the RotateFlip
method:
string sourceFile = dataDir + @"sample.psd";
string destName = dataDir + @"RotatingAnImage_out.jpg";
// Load an existing image into an instance of RasterImage class
using (Image image = Image.Load(sourceFile))
{
image.RotateFlip(RotateFlipType.Rotate270FlipNone);
image.Save(destName, new JpegOptions());
}
This code rotates the image by 45 degrees.
Flipping Images
To flip an image, you can use the Flip
method:
string sourceFile = @"sample.psd";
string destName = @"out.jpg";
// Load an image to be rotated in an instance of RasterImage
using (RasterImage image = (RasterImage)Image.Load(sourceFile))
{
image.Rotate(30f, true, Color.Green);
image.Save(destName, new JpegOptions());
}
This code flips the image horizontally.