Sometimes php will through a error when using the imagecreatefromjpeg() for some jpge images saved by cameras and photo editing softwares. When I search the internet for a solution I found this great article which fix the problem
http://worcesterwideweb.com/2008/03/17/php-5-and-imagecreatefromjpeg-recoverable-error-premature-end-of-jpeg-file/