Skip to content

Instantly share code, notes, and snippets.

@aspose-com-gists
Last active December 23, 2021 05:54
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 aspose-com-gists/6c6ccd35a9d4cda3d945e766554b9ae6 to your computer and use it in GitHub Desktop.
Save aspose-com-gists/6c6ccd35a9d4cda3d945e766554b9ae6 to your computer and use it in GitHub Desktop.
Convert PSD to TIFF Image with Compression Programmatically using Java
// Load a PSD file as an input image
Image psdImage = Image.load("layers.psd");
// Create an instance of TiffOptions
TiffOptions options = new TiffOptions(TiffExpectedFormat.TiffDeflateRgb);
// Set AdobeDeflate as TiffCompression method
options.setCompression(TiffCompressions.AdobeDeflate);
// Save output TIFF image
psdImage.save("TIFFwithDeflateCompression_out.tiff", options);
// Load a PSD file as an image and cast it into PsdImage
PsdImage psdImage = (PsdImage)com.aspose.psd.Image.load(dataDir + "layers.psd");
// Create an instance of TiffOptions for the resultant image
TiffOptions outputSettings = new TiffOptions(TiffExpectedFormat.Default);
// Set BitsPerSample, Compression, Photometric mode and graycale palette
int[] ushort = {4};
outputSettings.setBitsPerSample(ushort);
outputSettings.setCompression(TiffCompressions.Lzw);
outputSettings.setPhotometric(TiffPhotometrics.Palette);
outputSettings.setPalette(ColorPaletteHelper.create4BitGrayscale(true));
// Save output TIFF image
psdImage.save("SampleTiff_out.tiff", outputSettings);
// Load an existing PSD image as Image
com.aspose.psd.Image image = com.aspose.psd.Image.load("Photoshop.psd");
// Create an instance of TiffOptions class
com.aspose.psd.imageoptions.TiffOptions options = new com.aspose.psd.imageoptions.TiffOptions(com.aspose.psd.fileformats.tiff.enums.TiffExpectedFormat.Default);
// Convert PSD to Tiff
image.save("PSD-to-Tiff.tiff", options);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment