Manipulating BIGTIFF Images
Contents
[
Hide
]
Load bigtiff image and save to another format
BIGTIFF image can be easily loaded and saved to other supported image formats using Aspose.Imaging. Sample code shows how to process this.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.aspose.imaging.Image; | |
import com.aspose.imaging.RasterImage; | |
import com.aspose.imaging.fileformats.tiff.TiffFrame; | |
import com.aspose.imaging.fileformats.tiff.TiffImage; | |
import com.aspose.imaging.fileformats.tiff.TiffRational; | |
import com.aspose.imaging.fileformats.tiff.enums.*; | |
import com.aspose.imaging.imageoptions.TiffOptions; | |
import java.io.File; | |
String dataDir = "c:\\Users\\USER\\Downloads\\templates\\"; | |
// Create an instance of TiffOptions and set its various properties | |
TiffOptions options = new TiffOptions(TiffExpectedFormat.Default); | |
options.setBitsPerSample(new int[] { 8, 8, 8 }); | |
options.setPhotometric(TiffPhotometrics.Rgb); | |
options.setXresolution(new TiffRational(72)); | |
options.setYresolution(new TiffRational(72)); | |
options.setResolutionUnit(TiffResolutionUnits.Inch); | |
options.setPlanarConfiguration(TiffPlanarConfigs.Contiguous); | |
// Set the Compression to AdobeDeflate | |
options.setCompression(TiffCompressions.AdobeDeflate); | |
// Or Deflate | |
// options.setCompression(TiffCompressions.Deflate); | |
// Load an existing image in an instance of RasterImage | |
try (RasterImage image = (RasterImage) Image.load(dataDir + "template.tiff")) | |
{ | |
// Create a new TiffImage from the RasterImage and Save the resultant image while passing the instance of TiffOptions | |
try (TiffImage tiffImage = new TiffImage(new TiffFrame(image))) | |
{ | |
tiffImage.save(dataDir + "output.tiff", options); | |
} | |
} | |
// then delete it | |
new File(dataDir + "output.tiff").delete(); |