Warning: Imagejpeg() [Function:Imagejpeg]: Gd-Jpeg: Jpeg Library Reports Unrecoverable Error

Warning: imagejpeg() [function:imagejpeg]: gd-jpeg: JPEG library reports unrecoverable error

1) Check the space in disk

Your system must have enough disk space

2) Check the memory limit

Set more memory in your php:

ini_set("memory_limit","256M");

3) Check the post_max_size and upload_max_filesize

Set more in your htaccess file:

php_value post_max_size 16M
php_value upload_max_filesize 6M

4) put @ in front of the function

@imagejpeg(..............);

Point 1) worked for me.

imagecreatefromjpeg(): gd-jpeg: JPEG library reports unrecoverable error - Laravel

I know I am a bit late but I just had a similar problem and it was driving me crazy.

To answer your question " ...I am trying to figure it out, where I am creating an issue"... The error is being created at

$ffs = imagecreatefromjpeg($image);

This error came from executing this line of code, when uploading an image jpg and then working with it with the PHP GD2 Library

I followed the solution in the link below and it solved my issue.

http://anvilstudios.co.za/blog/2010/02/23/imagecreatefromjpeg-gd-jpeg-library-reports-unrecoverable-error/

I hope somebody will find this useful and save some time. Kudos to Nico from anvilstudios

Update
For those who cant access the link here is the code

$file_tempname = null;
if (is_uploaded_file($FILE['tmp_name'])) {
$file_tempname = $FILE['tmp_name'];
}
else{
exit('Wrong file type');
}

$file_dimensions = getimagesize($file_tempname);
$file_type = strtolower($file_dimensions['mime']);

if ($file_type=='image/jpeg'||$file_type=='image/pjpeg'){
if(imagecreatefromjpeg($file_tempname)){
$ffs = imagecreatefromjpeg($file_tempname);
return $ffs;
}
}

In PHP, why has imagecreatefromjpeg not a jpeg file changed to a fatal error?

I guess I can answer my own question. It's a known bug. See. PHP bugs #73514 and #73479. And actually the bug is in libgd, and has been reported there too. A fix was made last November, but still hasn't made it to a release. So, yeah... no luck. I'll try to use getimagesize() instead to determine the type first and use the appropriate function instead. That still won't help in the case of a genuinely corrupt file, but it's something.



Related Topics



Leave a reply



Submit