I have to recognize if a TIFF image is corrupted or not.
I've always used
file -b
to identify file type, but I've experienced that sometimes it returns "TIFF image data, little endian" even if the image is truncated or something.
Do you know another trick to check it?
the file command looks the the magic (first 4 bytes) of the file. Not the whole file.
In order to completely verify a tiff file you have to open it with a drawing/media program that handles these files. TIFF 6.0 is the current version, I think, and it does not specify a checksum, so you cannot calculate one to verify the file independently.
Plus. TIFF uses LZW compression, therefore, opening it to verify the data means using LZW decompresion on the data segment of the file.
That "trick" is meant for files that are corrupted in the file system, eg. missing blocks due to power loss. An incomplete TIFF file is still valid for the file system, as it doesn't care about the content.