This step by step tutorial will show you how to export CDR image to PSD format in C#. This simple C# code is able to create PSD image from CDR file using few lines of code.
Steps to Export CorelDRAW CDR Image to Photoshop PSD Format in C#
- Setup Aspose.Imaging for .NET package from Nuget.org
- Include reference to following three namespaces: Aspose.Imaging, Aspose.Imaging.FileFormats.Cdr and Aspose.Imaging.ImageOptions
- Set the license using SetLicense method before saving CDR image as PSD image
- Load the CorelDRAW CDR image file in CdrImage instance
- Set attributes of intended Photoshop PSD image using PsdOptions class instance
- Save the loaded CDR image file as PSD image on disk
In the above simple steps, we’re first loading a CDR image in CdrImage object using Load method of Image class. Once we have loaded the CDR image into the memory, we can save it to an output PSD image without using Photoshop. We can specify other attributes of the output PSD image as well.
Code to Export CorelDRAW CDR Image to Photoshop PSD Format in C#
using System; | |
using Aspose.Imaging; | |
using Aspose.Imaging.FileFormats.Cdr; | |
using Aspose.Imaging.ImageOptions; | |
namespace CDRToPSD | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
string PathForCDRFile = @"Y:\Downloads\"; | |
License license = new License(); | |
license.SetLicense(PathForCDRFile + "Conholdate.Total.Product.Family.lic"); | |
//Load the CDR file for converting to PSD | |
using (CdrImage CdrtoPSDImage = (CdrImage)Image.Load(@"MultiPage.cdr")) | |
{ | |
ImageOptionsBase CDRExportOptions = new PsdOptions(); | |
// If image is a multi-page then all pages are exported by default | |
CDRExportOptions.MultiPageOptions = new MultiPageOptions(); | |
//Export multiple pages in CDR as one layer by merger layer option | |
// Otherwise it will be exported page to page | |
CDRExportOptions.MultiPageOptions.MergeLayers = true; | |
// Setting rasterization options for fileformat | |
CDRExportOptions.VectorRasterizationOptions = (VectorRasterizationOptions)CdrtoPSDImage. | |
GetDefaultOptions(new object[] { Color.White, CdrtoPSDImage.Width, CdrtoPSDImage.Height }); | |
//Setting the smoothing mode of exported PSD | |
CDRExportOptions.VectorRasterizationOptions.SmoothingMode = SmoothingMode.None; | |
//Saving CDR to PSD | |
CdrtoPSDImage.Save(@"SavedPSD.psd", CDRExportOptions); | |
} | |
} | |
} | |
} |
In this example, we have used the default options for MultiPageOptions to merge and render all CDR pages in one PSD. There is other option to export each CDR image page as separate PSD by setting property MergeLayers to false. You can also change the enumerator value for SmoothingMode to set the quality of exported PSD image as well. Similarly, we can set other required properties or attributes to obtain varying quality PSD image.
In our previous topic, we explained the code to Create PNG image from BMP in C#.