PSD images are frequently used to design graphics and visuals. In some cases, you might want to crop or rotate a PSD image for different aesthetic requirements. In this article, you will learn how to crop or rotate a PSD image using C#. Please go through the following headings for more information:
- Rotate or Crop a PSD Image – C# .NET API Installation
- Crop a PSD Image with Shift Approach using C#
- Crop a PSD Image with Rectangular Coordinates in C#
- Rotate a PSD Image at any Angle using C#
Rotate or Crop a PSD Image – C# .NET API Installation
Aspose.PSD for .NET API supports creating, editing, and manipulating PSD and many other Photoshop file formats. You can easily set up the API by downloading the DLL file from the New Releases, or with the following NuGet installation command in Microsoft Visual Studio:
PM> Install-Package Aspose.PSD
Crop a PSD Image with Shift Approach using C#
You can crop a PSD image by moving the contents towards the center of the image. The following steps show how to crop a PSD image while shifting contents:
- Load the input PSD image using the RasterImage class instance.
- Cache the PSD image with CacheData method.
- Specify the shift values and call the Crop method.
- Save the output cropped image.
The code snippet explains how to crop a PSD image programmatically in C#:
Crop a PSD Image with Rectangular Coordinates in C#
You can crop any portion of a PSD image by using rectangular coordinates. Please follow the steps below in order to crop the PSD image with Rectangular coordinates:
- Load the input PSD file with RasterImage class.
- Cache the input image for enhanced performance.
- Initialize a Rectangle class object with the desired coordinates.
- Crop the PSD image and save the output file.
The following code snippet demonstrates how to crop a PSD image using rectangular coordinates in C#:
Rotate a PSD Image at any Angle using C#
You can rotate a PSD image at any angle with the following steps:
- Load the input PSD image with RasterImage class.
- Cache the image improved performance.
- Set the angle of rotation in the Rotate method.
- Save the rotated output PSD file.
The code snippet below explains how to rotate a PSD image programmatically in C#:
Get Free Evaluation License
You can request a free evaluation license to test the API in its full capacity.
In conclusion, you have learned how to crop or rotate a PSD image programmatically with C#. You can integrate the feature into your .NET-based applications. Please visit the documentation section for further details and feel free to write to us at the free support forum, in case of any inquiries.