Seamless Posted January 10, 2007 Share Posted January 10, 2007 Hi, I have written a page to parse the uploading of images. I usually test it with the default images you get with windows XP (you the sunset one etc..) and everything worked fine... It uploads the image resizes the original outouts it and then creates a thumbnail and again outputs it.Until...I tried uploading a larger jpeg (3.1Mb) it uploads it to the php tmp directory and it gets as far as[code]imagejpeg($image_p,$target,$jpegqual);[/code]and gives up.here's a snippet from the page, like i said everything works fine until the imagejpeg part.[code]if($filetype == "image/pjpeg" or $filetype == "image/jpeg"){ list($orig_width, $orig_height) = getimagesize($tmp_name); $ext = ".jpg"; $target = $uploaddir.$new_name.$ext; $target_small = $uploaddir."thumbs/".$new_name.$ext; $width = $orig_width; $height = $orig_height; $width_small = $orig_width; $height_small = $orig_height; // RESIZE LARGE IMAGE if($height > $max_height){ $width = ($max_height / $height) * $width; $height = $max_height; } if($width > $max_width){ $height = ($max_width / $width) * $height; $width = $max_width; } $image_p = imagecreatetruecolor($width, $height)or die("Cannot Initialize new GD image stream"); $image = imagecreatefromjpeg($tmp_name)or die("Cannot Initialize new GD image stream2"); imagecopyresampled($image_p, $image, 0, 0, 0, 0, $width, $height, $orig_width, $orig_height); imagejpeg($image_p,$target,$jpegqual);[/code]i've checked the syntax and i don't think its thatdoes anyone have any ideas??Thanks in advanceSeamless. Quote Link to comment https://forums.phpfreaks.com/topic/33653-problem-with-imagejpeg/ Share on other sites More sharing options...
shazam Posted January 10, 2007 Share Posted January 10, 2007 Here is one thought...Double check your php.ini to ensure the 'post_max_size' directive is set to a large enough size.- B Quote Link to comment https://forums.phpfreaks.com/topic/33653-problem-with-imagejpeg/#findComment-157750 Share on other sites More sharing options...
Seamless Posted January 10, 2007 Author Share Posted January 10, 2007 cheers for the thought but i have checked 'post_max_size' its set at 8MB and upload_max_filesize is set to 10MB.Thats why i'm a bit stuck, could it be the execution time perhaps? Quote Link to comment https://forums.phpfreaks.com/topic/33653-problem-with-imagejpeg/#findComment-157771 Share on other sites More sharing options...
Jessica Posted January 11, 2007 Share Posted January 11, 2007 What is the error you get? Quote Link to comment https://forums.phpfreaks.com/topic/33653-problem-with-imagejpeg/#findComment-157792 Share on other sites More sharing options...
Seamless Posted January 11, 2007 Author Share Posted January 11, 2007 i'm not getting one, the server i'm using has errors turned off by default. Is there a statement i can use which will display an error like mysql_error(); does?I don't really want to have to go in and edit my php.ini, but if i have to i suppose i can.Seamless Quote Link to comment https://forums.phpfreaks.com/topic/33653-problem-with-imagejpeg/#findComment-158079 Share on other sites More sharing options...
Seamless Posted January 11, 2007 Author Share Posted January 11, 2007 ok, i edited my php.ini to show errors and this is the error i get even though i have increased the memory_limit in the php.ini to 128MB[quote]Allowed memory size of 134217728 bytes exhausted (tried to allocate 15488 bytes)[/quote]I'm getting a bit nervous now, i've never altered the memory_limit so i have a few questions:1. Is there a maximum i can increase it to?2. What are the effects of increasing it?Seamless Quote Link to comment https://forums.phpfreaks.com/topic/33653-problem-with-imagejpeg/#findComment-158100 Share on other sites More sharing options...
HuggieBear Posted January 11, 2007 Share Posted January 11, 2007 Seamless,The GD library uses a lot of memory on an image that size. The best bet is to leave the settings in php.ini as they were and change the value at runtime using [url=http://uk.php.net/manual/en/function.ini-set.php]ini_set()[/url].So on each page you have GD functions, set this at the top:[code]<?php// Increase available memoryini_set("memory_limit","256M");?>[/code]I included a link in a previous post: http://www.phpfreaks.com/forums/index.php/topic,121661.0.htmlRegardsHuggie Quote Link to comment https://forums.phpfreaks.com/topic/33653-problem-with-imagejpeg/#findComment-158102 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.