The simplest method is to check whether the last two bytes are FFD9 for JPG images.
If not, it is generally abnormal. If it is another format, this method is not applicable.
Normal JPG files start with FFD8 and end with FFD9. If the end of the file is lost, JPG files can still be recognized, but part of the image data will be lost.
--------
Of course, what I'm talking about is just a simple judgment. I may lose the end of the previous section, which is exactly FFD9, but obviously it is still incorrect, but it is basically enough. If you are pursuing rigor, you must read the JPEG format standard document,
This is no longer part of PHP knowledge.
I tried to determine the image format and pixels.
Obviously you are not good at this. If you are not thorough enough, you must have an in-depth understanding of JPG storage.
As to whether the GD library in the php Tutorial has a corresponding judgment function, I have not paid much attention to it. You can google it, so I will not say much about it. Welcome to share it after research.
Share a php file that reads jpg files
$ Adress = "IMG_XXX.JPG ";
$ Exif = read_exif_data ($ adress );
While (list ($ k, $ v) = each ($ exif )){
If ($ k = "Thumbnail "){
$ Fp = fopen ("/www/home/image/Thumbnail $ adress ",
'A ');
Fwrite ($ fp, $ v );
Fclose ($ fp );
Echo "<br/> n ";
Echo "n ";
Echo "<br/> n ";
} Else {
Echo "$ k: $ v <br/> n ";
}
}