Free Support Forum - aspose.com

Get Current TIFF Compression Type

When I open a TIFF image from file, I need to evaluate its current compression type before proceeding. I know how to set the compression type before saving a TiffImage, but I cannot find a property that will expose the existing compression when I open one.

@smclean,

I have tried to understand your requirements and have not been able to completely understand them. Can you please elaborate your following requirements in details.

OK…

When I load a file into a TiffImage object, I want to check what conversion type it already is (e.g. CCITT4 or LZW)

I am converting files to LZW, but I don’t want to convert files that are already LZW, for example.

@smclean,

I have observed your comments and they seems to be a new requirement now. I request you to please provide sample code, source file, generated file and desired output file that you like to generate using Aspose.Imaging. I’ll be able to investigate your requirements on provision of requested information and further elebiration of your requirements

No problem

The scenario is very simple:

// I open a TIFF image from file
string path = @"C:\Some\Path\To\ImageFile.tif";
var tiff = (TiffImage)Aspose.Imaging.Image.FromFile(path);

// I then want to determine what compression type it was using before loading it
var tiffCompressionType = tiff.???;

Here the “???” is in place because I cannot find any property of the TiffImage class that will reveal the current compression type of the image that I loaded into the variable called “tiff”

@smclean,

I have observed the sample code shared by you and regret to share that at present the support for getting compression type is not available in API. An issue with ID IMAGINGNET-3027 has been created in our issue tracking system to provide requested support. This thread has been linked with the issue so that you may be notified once the support will be available.

@smclean,

I suggest you to please try using following sample code on your end to serve the purpose.

using (var image = (TiffImage)Image.Load("CCITTFax4.tif"))
{
    foreach(var frame in image.Frames)
    {
        Console.WriteLine("compression = " + frame.FrameOptions.Compression);
    }
}

The issues you have found earlier (filed as IMAGINGNET-3027) have been fixed in this update.