floridaflatlander Posted March 17, 2011 Share Posted March 17, 2011 I Can't resize large images with imagecreatefromjpeg() I can load small 38kb images fine, when they get up 780+- or 1.3 mb +- (with a width of 2500px * x) I get the below error I also can upload the same pics in another file with out resizing(using imagecreatefromjpeg()) them and the script works fine. my max file upload size with xampp is 128mb / php5 Warning: imagecreatefromjpeg() [function.imagecreatefromjpeg]: gd-jpeg, libjpeg: recoverable error: Corrupt JPEG data: 191 extraneous bytes before marker 0xd9 in C:\xampp\htdocs\ed\phpsol\ch08\work\includes\create_thumb.inc.php on line 35 Warning: imagecreatefromjpeg() [function.imagecreatefromjpeg]: 'C:\xampp\tmp\php9596.tmp' is not a valid JPEG file in C:\xampp\htdocs\ed\phpsol\ch08\work\includes\create_thumb.inc.php on line 35 I'm basicly using a switch switch($type) { case 1: $source = @ imagecreatefromgif($original); if (!$source) { $result = 'Cannot process GIF files. Please use JPEG or PNG.'; } break; case 2: $source = imagecreatefromjpeg($original); <---- LINE 35 where $original is $original = $_FILES['image']['tmp_name']; break; Quote Link to comment https://forums.phpfreaks.com/topic/230950-cant-resize-large-images-with-imagecreatefromjpeg/ Share on other sites More sharing options...
ChemicalBliss Posted March 17, 2011 Share Posted March 17, 2011 Check your memory_limit in your php.ini. If it's a hosted server, then you might not be able to change it, especially if it's a free host. Impose a maximum filesize and make them do the bulk of the resizing, even paint can resize images (albeit bad quality), but many free apps can do it easily. If you really want that functionality you will need to use ini_set: ini_set("memory_limit", "30M"); // Should be, I would say, 10% larger than the max file size you want users to upload. You can use ini_get to see what the memory limit is atm, i am guessing yours is at 8MB echo(ini_get("memory_limit")); You can also use HTACCESS files or edit the php.ini directly but i highly discourage this as it will use memory that it probably wont need 99% of the time. Quote Link to comment https://forums.phpfreaks.com/topic/230950-cant-resize-large-images-with-imagecreatefromjpeg/#findComment-1188831 Share on other sites More sharing options...
floridaflatlander Posted March 17, 2011 Author Share Posted March 17, 2011 I checked my php.ini and xwampp has a setting if 128m for memory_limit. And even though memory_limit is set to 128m I added "ini_set("memory_limit", "30M");" anyway and I still got the same message. Like I said in my first post I can up large load images if I don't use imagecreatefromjpeg() so memoy_limit shouldn't be the problem, I think. Thanks SJ Quote Link to comment https://forums.phpfreaks.com/topic/230950-cant-resize-large-images-with-imagecreatefromjpeg/#findComment-1188875 Share on other sites More sharing options...
floridaflatlander Posted March 17, 2011 Author Share Posted March 17, 2011 OKay I was looking at http://php.net/manual/en/function.imagecreatefromjpeg.php and noticed a lot of the problems came from cannon cameras so I tried photos from another camea and the code worked like a charm. Now all I got to do his find out how to get it to work with all cameras. I guess I am a php "Irregular" cause right now I'm going for a walk. Thanks for the help ChemicalBliss, maybe I can get this ironed out later. SJ Quote Link to comment https://forums.phpfreaks.com/topic/230950-cant-resize-large-images-with-imagecreatefromjpeg/#findComment-1188930 Share on other sites More sharing options...
floridaflatlander Posted March 18, 2011 Author Share Posted March 18, 2011 There seems to very little info on this and after looking & playing I've found problems on the internet with several different cameras and even a mention of IE. When I took the problem pics and save them again at same size the code worked. Last I tried to upload to coppermine & got "The image you have uploaded is corrupted or can't be handled by the GD library". Sooo I'm going to go with that for now. All these pics are from a friend and I haven't contacted them to see what type of camera they use. Quote Link to comment https://forums.phpfreaks.com/topic/230950-cant-resize-large-images-with-imagecreatefromjpeg/#findComment-1189130 Share on other sites More sharing options...
ChemicalBliss Posted March 19, 2011 Share Posted March 19, 2011 You might want to try something like this: http://www.ozhiker.com/electronics/pjmt/index.html Quote Link to comment https://forums.phpfreaks.com/topic/230950-cant-resize-large-images-with-imagecreatefromjpeg/#findComment-1189375 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.