Jessica Posted June 13, 2006 Share Posted June 13, 2006 Fatal error: Allowed memory size of 8388608 bytes exhausted (tried to allocate 4252 bytes) in /home/www/sites/lifefiles.com/admin/uploadphotos.php on line 41[code]function resize_image($type, $file, $max_width, $max_height){ $full_url = $file; $imageinfo = getimagesize($file); $src_width = $imageinfo[0]; $src_height = $imageinfo[1]; if($src_width > $max_width){ $divide = $imageinfo[0] / $max_width; } if($src_height > $max_height){ $divide = $imageinfo[1] / $max_height; } $dest_width = $src_width / $divide; $dest_height = $src_height / $divide; if($type == 2){ $src_img = imagecreatefromjpeg($file); (<-- Line 41) }else{ $src_img = imagecreatefromgif($file); } $dst_img = imagecreatetruecolor($dest_width,$dest_height); imagecopyresampled($dst_img, $src_img, 0, 0, 0, 0, $dest_width, $dest_height, $src_width, $src_height); if($type == 2){ imagejpeg($dst_img,$full_url); }else{ imagegif($dst_img,$full_url); } imagedestroy($src_img); }[/code]The file is a very large one, and I need to be able to do the resize. How do I make it use more memory? Quote Link to comment https://forums.phpfreaks.com/topic/11878-allowed-memory-size-exhausted/ Share on other sites More sharing options...
bluebutterflyofyourmind Posted August 24, 2008 Share Posted August 24, 2008 I have the same problem. though this is happening on relatively small files. ie: <1MB not sure how to fix this. neone? Quote Link to comment https://forums.phpfreaks.com/topic/11878-allowed-memory-size-exhausted/#findComment-624019 Share on other sites More sharing options...
DarkWater Posted August 24, 2008 Share Posted August 24, 2008 Firstly, are you on a shared hosting plan? Because they often have low memory limits for PHP so the whole server isn't backed up. >_> Secondly, how big of an image are we talking about here? Quote Link to comment https://forums.phpfreaks.com/topic/11878-allowed-memory-size-exhausted/#findComment-624047 Share on other sites More sharing options...
bluebutterflyofyourmind Posted August 24, 2008 Share Posted August 24, 2008 I am on shared hosting but i think i might have figured out some stuffso i tried my functions again with different images and it worked....the image that failed was ont 500 kb but had dimension of about 3000x2500i tried another image that was 1.5MB but on 2000x1900 and it worked.I think imagecopyfromjpeg() can't handel such large dimensions. does this make sense? is there a way around this?thanks!grant Quote Link to comment https://forums.phpfreaks.com/topic/11878-allowed-memory-size-exhausted/#findComment-624051 Share on other sites More sharing options...
DarkWater Posted August 24, 2008 Share Posted August 24, 2008 [quote author=bluebutterflyofyourmind link=topic=95750.msg972939#msg972939 date=1219542405]I am on shared hosting but i think i might have figured out some stuffso i tried my functions again with different images and it worked....the image that failed was ont 500 kb but had dimension of about 3000x2500i tried another image that was 1.5MB but on 2000x1900 and it worked.I think imagecopyfromjpeg() can't handel such large dimensions. does this make sense? is there a way around this?thanks!grant[/quote]Can you send me the image? I'll try playing with it on my own server with an image effects class I made and see if it's your server that's the problem, or if it's the actual function. Quote Link to comment https://forums.phpfreaks.com/topic/11878-allowed-memory-size-exhausted/#findComment-624055 Share on other sites More sharing options...
bluebutterflyofyourmind Posted August 24, 2008 Share Posted August 24, 2008 here ya go. just go here and download.[url=http://grantlucas.com/flower_Version2.jpg]http://grantlucas.com/flower_Version2.jpg[/url]i tried on another server i rent from and i got the same problem. deffinately thinking it's the pixel dimensions that are messing things up. Quote Link to comment https://forums.phpfreaks.com/topic/11878-allowed-memory-size-exhausted/#findComment-624069 Share on other sites More sharing options...
DarkWater Posted August 24, 2008 Share Posted August 24, 2008 Works for my image class that I made. >_> I think it's your host's memory limit. Quote Link to comment https://forums.phpfreaks.com/topic/11878-allowed-memory-size-exhausted/#findComment-624072 Share on other sites More sharing options...
bluebutterflyofyourmind Posted August 24, 2008 Share Posted August 24, 2008 yikes. really? crazy. i tried it on two different hosts and i'm allowing up to 40 MB uploads. just run into problems with large dimensions. does this memory limit have to do with file size or other factors? Quote Link to comment https://forums.phpfreaks.com/topic/11878-allowed-memory-size-exhausted/#findComment-624073 Share on other sites More sharing options...
DarkWater Posted August 24, 2008 Share Posted August 24, 2008 It has to do with the amount of processing power that loading an image of that size takes. It has nothing to do with upload size, just memory limit size. Quote Link to comment https://forums.phpfreaks.com/topic/11878-allowed-memory-size-exhausted/#findComment-624075 Share on other sites More sharing options...
bluebutterflyofyourmind Posted August 24, 2008 Share Posted August 24, 2008 hm that sucks. so it's NOT a problem having to do with the imagecopyjpeg() function? is that what you used as well? Quote Link to comment https://forums.phpfreaks.com/topic/11878-allowed-memory-size-exhausted/#findComment-624076 Share on other sites More sharing options...
DarkWater Posted August 24, 2008 Share Posted August 24, 2008 You mean imagecreatefromjpeg()? Quote Link to comment https://forums.phpfreaks.com/topic/11878-allowed-memory-size-exhausted/#findComment-624079 Share on other sites More sharing options...
bluebutterflyofyourmind Posted August 24, 2008 Share Posted August 24, 2008 yeah Quote Link to comment https://forums.phpfreaks.com/topic/11878-allowed-memory-size-exhausted/#findComment-624081 Share on other sites More sharing options...
DarkWater Posted August 24, 2008 Share Posted August 24, 2008 Actually, I test to make sure it's an image and then use:$this->image = imagecreatefromstring(file_get_contents($filename));That way I don't need to deal with the different functions. >_> It's still your host's limit when it comes down to it though. Quote Link to comment https://forums.phpfreaks.com/topic/11878-allowed-memory-size-exhausted/#findComment-624082 Share on other sites More sharing options...
bluebutterflyofyourmind Posted August 24, 2008 Share Posted August 24, 2008 ah ok. thanks for the help! Quote Link to comment https://forums.phpfreaks.com/topic/11878-allowed-memory-size-exhausted/#findComment-624085 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.