Is there a way to determine the file type by directly scanning the file itself, rather than reading it from the header? I know it seems like overkill...but I don't want someone to be able to edit the mime-type of a file (say changing it from "image/png" to "image/gif") and then do the same thing with the file extension, without me being able to tell.
I experimented with this by using the ImageMagick method setImageFormat to change a jpeg to a gif. Then I saved it to the harddrive with writeImage and retrieved it again using GD. Then I used the imagecreatefromgif function on it, and it returned true, even though it was still really a jpeg.
Is there any kind of test that will return false if the file contents don't agree with the mime-type?