I'm trying to load an image from an external site over which I have no control.
Most of the time it works fine (hundreds of images tested so far).
It's now giving me this error for one particular image:
imagecreatefromstring(): gd-jpeg, libjpeg: recoverable error: Corrupt JPEG data: premature end of data segment
from this line:
$im = @imagecreatefromstring( $imageString );
The advice I'd read so far suggests adding:
ini_set("gd.jpeg_ignore_warning", true);
but that's had no effect and I'm still getting the error. I'm doing the ini_set just before the call. Is that relevant?
I'm really stuck on how to ignore this error and carry on.
The problem was due to my error handling. I'd set up an error handler so my call to
$im = @imagecreatefromstring( $imageString );
wasn't suppressing errors.
By modifying my error handler with:
if (error_reporting() === 0)
{
// This copes with @ being used to suppress errors
// continue script execution, skipping standard PHP error handler
return false;
}
I can now correctly suppress selected errors.
I found the info here: http://anvilstudios.co.za/blog/php/how-to-ignore-errors-in-a-custom-php-error-handler/
this can be solve with:
ini_set ('gd.jpeg_ignore_warning', 1);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With