neoform Posted March 25, 2007 Share Posted March 25, 2007 for some reason random jpeg files that i upload and try to process with imagecreatefromjpeg() causes php to fail/die. I have no idea why, since it's not throwing any errors.. just get a white screen (only for certain jpgs) Link to comment https://forums.phpfreaks.com/topic/44265-imagecreatefromjpeg-dies-for-some-images/ Share on other sites More sharing options...
Waldir Posted March 25, 2007 Share Posted March 25, 2007 <?php function LoadJpeg($imgname) { $im = @imagecreatefromjpeg($imgname); /* Attempt to open */ if (!$im) { /* See if it failed */ $im = imagecreatetruecolor(150, 30); /* Create a black image */ $bgc = imagecolorallocate($im, 255, 255, 255); $tc = imagecolorallocate($im, 0, 0, 0); imagefilledrectangle($im, 0, 0, 150, 30, $bgc); /* Output an errmsg */ imagestring($im, 1, 5, 5, "Error loading $imgname", $tc); } return $im; } header("Content-Type: image/jpeg"); $img = LoadJpeg("bogus.image"); imagejpeg($img); ?> Link to comment https://forums.phpfreaks.com/topic/44265-imagecreatefromjpeg-dies-for-some-images/#findComment-215007 Share on other sites More sharing options...
neoform Posted March 25, 2007 Author Share Posted March 25, 2007 didn't work. It always fails on the line with imagecreatefromjpeg().. so this dies right here: $im = @imagecreatefromjpeg($imgname); /* Attempt to open */ if i try reloading the page after i get a blank page, i get this error: WARNING - imagecreatefromjpeg() [function.imagecreatefromjpeg]: gd-jpeg: JPEG library reports unrecoverable error: (line: 61) Link to comment https://forums.phpfreaks.com/topic/44265-imagecreatefromjpeg-dies-for-some-images/#findComment-215009 Share on other sites More sharing options...
Waldir Posted March 25, 2007 Share Posted March 25, 2007 try adding if(file_exists()) to see if its a problem with the path Link to comment https://forums.phpfreaks.com/topic/44265-imagecreatefromjpeg-dies-for-some-images/#findComment-215010 Share on other sites More sharing options...
neoform Posted March 25, 2007 Author Share Posted March 25, 2007 it's not, cause i was able to replace the dying function with header("Content-Type: image/jpeg"); readfile($path); and it loads the image perfectly.. Link to comment https://forums.phpfreaks.com/topic/44265-imagecreatefromjpeg-dies-for-some-images/#findComment-215017 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.