I sometimes get files from my clients that have the wrong file extension. For example, the name is image.jpg but the file is actually a TIFF image. In many cases I can clarify it by opening the file in a text editor, looking at the first few bytes, then deducing which file type it is.
This works for me with JPEG, TIFF, GIF and PDF files. However there are many more file types out there.
Is it possible to automate identification of the correct file type by analyzing the containing data?

