in reply to Opinions on determining mime type

I've used Image::Magick to do this before. In my installation I used it to identify the format, convert certain formats to others (for instance, I had it convert all non-animanted GIF's with no transparent colors to PNG's). It is also good for making sure it is a valid image (not some person uploading a word document where they should be uploading a graphic). I also used it to automatically scale the images to a certain maximum allowable size for the site in question. Image::Magic can bia bit heavy, but it is the swiss-army knife of perl image manipulation modules and can handle all common and manu not-so-common image formats.