March 17, 2008
Ok I recently came up with a problem creating thumbnails for a project I am working on. I was stumped for hours, it seems that some files that were saved from a mac or certain photo editing programs would cause php to not recognize it a jpg thus giving the error:
imagecreatefromjpeg() : gd-jpeg, libjpeg: recoverable error: Premature end of JPEG
After researching this problem I realized it was a problem with php 5 and gd2. Heres how to fix it
- php 4 : No action neccesarry it should work fine
- php 5.0 - 5.1.2 = Upgrade to the latest php 5
- php 5.1.3 - current = Declare this variable in your file before calling imagecreatefromjpeg()
ini_set(’gd.jpeg_ignore_warning’, 1);
Doing that will cause gd2,php to ignore the error and continue where it use to just fail and do nothing.
Posted by Anthony LeBoeuf under PHP | Comments (8)