Skip to content

Instantly share code, notes, and snippets.

@aspose-com-gists
Last active September 15, 2022 09:56
using Aspose.Imaging;
using Aspose.Imaging.FileFormats.Psd;
using Aspose.Imaging.ImageOptions;
string templatesFolder = @"c:\Users\USER\Downloads\templates\";
Run();
void Run()
{
// The path to the documents directory.
string dataDir = templatesFolder;
string inputFileName = dataDir + "template.cmx";
//Export vector image to PSD format keeping vector shapes
//Aspose.Imaging allows to export vector image formats such as CDR, EMF, EPS, ODG, SVG, WMF to the PSD format,
//while keeping vector properties of the original, utilizing PSD Shapes, Paths //and Vector Masks.
//Currently, export of not very complex shapes is supported, whithout texture brushes or open shapes with stroke,
//which will be improved in the upcoming releases.
//Example
//Export from the CDR format to the PSD format preserving vector
//properties is as simple as the following snippet:
using (Image image = Image.Load(inputFileName))
{
PsdOptions imageOptions = new PsdOptions()
{
VectorRasterizationOptions = new VectorRasterizationOptions(),
VectorizationOptions = new PsdVectorizationOptions()
{
VectorDataCompositionMode = VectorDataCompositionMode.SeparateLayers
}
};
imageOptions.VectorRasterizationOptions.PageWidth = image.Width;
imageOptions.VectorRasterizationOptions.PageHeight = image.Height;
image.Save(dataDir + "result.psd", imageOptions);
}
System.IO.File.Delete(dataDir + "result.psd");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment