Error Description:
Imagecreatefromjpeg returns BOOL (false)
Imagecreatefromjpeg (): Xxx.jpg is not a valid JPEG file
Imagecreatefromjpeg (): Gd-jpeg:jpeg Library reports unrecoverable error
PHP Load Image function:
Imagecreatefromgif ()
Imagecreatefromjpeg ()
Imagecreatefrompng ()
Imagecreatefromwbmp ()
Imagecreatefromstring ()
Function: Creates a new image from a file or URL or image stream in a string, returns the image resource after success, and returns false after failure.
PS: A simple understanding of its role is to be divided into the image temporarily read in memory.
Error NOTE:
Error message translation: Picture is not a valid JPEG file
Error Reason:
This error is usually caused by inconsistencies in the function and image format used to process the picture, such as the PNG-formatted picture you are using the Imagecreatefromjpeg function.
Of course, you can be puzzled: the image extension is. jpg, with the Imagecreatefromjpeg function to deal with there is no wrong place ah?
In general, the picture's extension and the picture's format are the same. But there are times when the extension of the picture and the inconsistency of the image format, such as human modification, the image of PNG or GIF changed the extension to JPG, so sometimes the extension we see is not necessarily the correct extension of the picture file. So the program will throw the error back in the process.
Solution Idea:
Use the getimagesize function to get a picture format when you are working on a picture, and then judge the image processing function that you use. Also, determine if the return value is False, and if false, try a different function type.