2005.05.31 23:56 "Re: [Tiff] hot to detect corrupt tif file", by Andy Cave
Two things that 'work':
- Do a basic open on the tiff file. If that succeeds, you've got a good chance it's a tiff file.
- Read the band/tile offsets & sizes, and check that 'they make sense' - that is that each band/tile offsets & offset+size lies within the physical size of the file (assuming it's a file). If the file is corrupt, there is a good chance that this will fail.
After that, the only thing you can do to check there is no corruption, is to read each band/tile (and decompress it et al). But that's a lot of overhead.
So, I'd suggest the first 2. We do that with our product FirstPROOF, and it seems to be a reasonable catch of corrupt files.
Chief Executive Officer,
Hamillroad Software Limited.
----- Original Message -----
From: "Bruno LEDOUX" <email@example.com>
Sent: Wednesday, June 01, 2005 12:46 AM
Subject: Re: [Tiff] hot to detect corrupt tif file
> Hi Gordon,
> Not sure exactly what you mean by "corrupt tiff file".
> If you want to check that the CONTENT of a TIFF file hasn't been altered, > you will have to use an external CRC method like MD5 as there is no such
> thing as a checksum in the TIFF format.
> If you want to determine the file format, you can use
> TIFFOpen("file_to_check","r"). If it returns NULL it means the file is NOT
> TIFF file. If you want to perform more detailed checks it going to be more > complex considering the number of different tag formats.
>> We are trying to find a way to check a tif file and find out whether >> or not it is a corrupt tif file. Any idea I can do that with libtiff
>> Thanks, Gordon