How can I programatically determine the image format of an image file, including the specific encoding such as the TIFF group?
if you don't find any ready-made library I guess you should open the file as binary and look for the header data, which means you have to know how the header looks like for every format you would like to support.