Hello!
I have some TIFF images that are compressed with LZW, but an older application we have doesn’t like LZW. Can I use Aspose.PDF to convert a TIFF to a different compression format?
Thanks!
Doug
Hi Doug,
Thanks for contacting support.
Aspose.Pdf for .NET provides the feature to create as well as manipulate existing PDF files. As per your requirement, you may consider first converting TIFF image to PDF format and then convert PDF pages to TIFF image with desired compression. For more information, please visit
Besides this, we have an API named Aspose.Imaging which provides the support to deal with various image formats. I am moving this thread to respective forum where my fellow worker from respective team will further share his feedback.
Hi Doug,
//Load input Tiff image
TiffImage source = (TiffImage)Image.Load(myDir + “sample.tif”);
//Create an instance of TiffOptions for resultant Tiff image
TiffOptions options = new TiffOptions();
//Set the source for resultant Tiff image
options.Source = new FileCreateSource(myDir + “result.tif”, false);
//Create a new Tiff image while passing the instance of TiffOptions & expected image dimensions
{
//Tiff image may contain more than one frame
//Iterate over the collection of input image frames
foreach (TiffFrame frame in source.Frames)
{
//Create a copy of the frame for further processing
TiffFrame copiedFrame = TiffFrame.CopyFrame(frame);
//In a multi-page Tiff image, we can set the different compression for each frame
copiedFrame.FrameOptions.Compression = TiffCompressions.CcittFax3;
//Set the BitsPerSample for the frame: The value depends on the compression type selected
copiedFrame.FrameOptions.BitsPerSample = new ushort[] { 1 };
//Set the Photometric for the frame: The value depends on the compression type selected
copiedFrame.FrameOptions.Photometric = TiffPhotometrics.MinIsBlack;
//Add copied frame to the destination image
result.AddFrame(copiedFrame);
}
//The first frame is created by default, we may just remove it as it is empty
//But it is not possible to remove the empty frame unless there are more than one frames
if (result.Frames.Length > 1)
{
//Set next frame as Active
result.ActiveFrame = result.Frames[1];
//Remove the first frame
result.RemoveFrame(0);
}
// Save the image with changes
result.Save();
}