2005.06.01 00:02 "Re: [Tiff] hot to detect corrupt tif file", by Bob Friesenhahn
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.
A TIFF file can experience a *huge* amount of corruption which is undetectable to a TIFF reader. The entire raster area could be corrupt.
GraphicsMagick Maintainer, http://www.GraphicsMagick.org/