tags:

views:

165

answers:

1

I'm trying to create a thumbnail / cutout of a larger image and it works for a large percentage of the time but every now and again I get the following:

  Warning: imagecreatefromjpeg(): gd-jpeg, libjpeg: recoverable error: Corrupt
  JPEG data: 626 extraneous bytes before marker 0xd9 in code.php on line 5

This is line 5 of "code.php":

 $srcImg  = imagecreatefromjpeg('5f48ecb107a1e297d23392f703992d60.jpg');

The image displays fine in windows but gd just fails to create the resource so I end up with a blank image (where the cutout section was supposed to go).

For frame of reference this is with regard to car titles and the system has 2784 that worked and only 36 that didn't so not a big deal but it has my curiosity piqued.

A: 

It sounds much like this problem reported on another web site, and the PHP bug is ticket #29878 (unavailable when I checked).

Although you should also verify that the image file is a valid, non-corrupt, JPEG image file as well. ImageMagick's identify program can identify if the file is corrupt. One potential problem is a JPEG file that uses CYMK rather than RGB colormap. ImageMagick can also likely let you resave the image to a valid JPEG file if corrupted.

mctylr
Thank you Mr. Taylor! The following "fixed" the issue: ini_set('gd.jpeg_ignore_warning', 1);
Rob