sasori Posted October 23, 2014 Share Posted October 23, 2014 (edited) Hi, before posting this problem, I already tried googling and tried those possible solutions that could help but still failed. I am having a problem with that PHP function imagecreatefromjpeg(): gd-jpeg: JPEG library reports unrecoverable error: based from what i found in google, some say, use ini_set("gd.jpeg_ignore_warning", 1); failed. some say, use init_set("memory_limit", -1) still failed I am sure that I am passing .jpg image, how come i keep on getting that error ? any suggestions of what to do? Edited October 23, 2014 by sasori Quote Link to comment https://forums.phpfreaks.com/topic/292007-imagecreatefromjpeg-error-help/ Share on other sites More sharing options...
jcbones Posted October 23, 2014 Share Posted October 23, 2014 How are you "sure that I am passing .jpg image"? Are you checking it? Are you checking the mime? Are you checking the extension? Are you sure it isn't a script that has been faked as an image?Basically, show us the code. Quote Link to comment https://forums.phpfreaks.com/topic/292007-imagecreatefromjpeg-error-help/#findComment-1494471 Share on other sites More sharing options...
sasori Posted October 23, 2014 Author Share Posted October 23, 2014 (edited) it's not a script..i have a alot of random images in my local storage that i usually use for testing ... here's the part of the code $fext = pathinfo($url, PATHINFO_EXTENSION); $tmp_name = date('His') . rand() . "." . $fext; $filename = $path .'/'. $tmp_name; $cont = @file_get_contents($url); $op = @fopen($filename, 'w+'); @fwrite($op, $cont); @fclose($op); chmod($filename, 0777); $orientation = 999; $exif = null; if (strtolower($fext) == 'jpg' || strtolower($fext) == 'jpeg') { try { $exif = @exif_read_data($filename); } catch (Exception $e) { Yii::log($e->getMessage()); }; if (!empty($exif) && !empty($exif['Orientation'])) { $orientation = $exif['Orientation']; } $img = imagecreatefromjpeg($filename); Edited October 23, 2014 by sasori Quote Link to comment https://forums.phpfreaks.com/topic/292007-imagecreatefromjpeg-error-help/#findComment-1494474 Share on other sites More sharing options...
MDCode Posted October 23, 2014 Share Posted October 23, 2014 Check the headers of the file. The extension can be jpeg, but the headers are what gets checked. Quote Link to comment https://forums.phpfreaks.com/topic/292007-imagecreatefromjpeg-error-help/#findComment-1494479 Share on other sites More sharing options...
sasori Posted October 23, 2014 Author Share Posted October 23, 2014 (edited) Check the headers of the file. The extension can be jpeg, but the headers are what gets checked. it's a jpeg image...how come other jpegs are being read without problems at all? here are the two images, the baby apparel is ok, but the knitted hat is causing that error I mentioned in this thread.. i'm not sure if this forum modified those files that i just attached in this reply Edited October 23, 2014 by sasori Quote Link to comment https://forums.phpfreaks.com/topic/292007-imagecreatefromjpeg-error-help/#findComment-1494485 Share on other sites More sharing options...
Solution MDCode Posted October 23, 2014 Solution Share Posted October 23, 2014 Remove the error suppresing and see if anything happens. Quote Link to comment https://forums.phpfreaks.com/topic/292007-imagecreatefromjpeg-error-help/#findComment-1494489 Share on other sites More sharing options...
sasori Posted October 24, 2014 Author Share Posted October 24, 2014 the thing that has caused the issue is the white space in the image name...to fix the issue.. the sencha front-end code is now encoding the url being passed to me Quote Link to comment https://forums.phpfreaks.com/topic/292007-imagecreatefromjpeg-error-help/#findComment-1494589 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.