Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ESidenko/87553f5092de1133af8405efde64b184 to your computer and use it in GitHub Desktop.
Save ESidenko/87553f5092de1133af8405efde64b184 to your computer and use it in GitHub Desktop.
import com.aspose.imaging.Image;
import com.aspose.imaging.fileformats.psd.VectorDataCompositionMode;
import com.aspose.imaging.imageoptions.PsdOptions;
import com.aspose.imaging.imageoptions.PsdVectorizationOptions;
import com.aspose.imaging.imageoptions.VectorRasterizationOptions;
// The path to the document directory.
String dataDir = "c:\\templates\\";
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, without 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:
try(Image image = Image.load(inputFileName))
{
PsdOptions imageOptions = new PsdOptions();
final VectorRasterizationOptions rasterizationOptions = new VectorRasterizationOptions();
rasterizationOptions.setPageWidth(image.getWidth());
rasterizationOptions.setPageHeight(image.getHeight());
imageOptions.setVectorRasterizationOptions(rasterizationOptions);
imageOptions.setVectorizationOptions(new PsdVectorizationOptions() {{ setVectorDataCompositionMode(VectorDataCompositionMode.SeparateLayers); }});
image.save(dataDir + "result.psd", imageOptions);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment