TalkPHP

TalkPHP (http://www.talkphp.com/forums.php)
-   General (http://www.talkphp.com/general/)
-   -   GD Exceeding Memory Size... What? (http://www.talkphp.com/general/5049-gd-exceeding-memory-size-what.html)

Aaron 10-22-2009 05:58 AM

GD Exceeding Memory Size... What?
 
Fatal error:Allowed memory size of 16777216 bytes exhausted (tried to allocate 2816 bytes) in W:\htdocs\xxx\index.php on line 62


PHP Code:

function createThumbs($rawImage$imgDir){
  
chdir($imgDir);
  
$thumbDir '/thumbs/';
  if (!
file_exists($thumbDir)){
    
mkdir($thumbDir);
  }
  
$filename $rawImage;
  
$thumbHeight 300;
  
header('(anti-spam-(anti-spam-content-type:)) image/jpeg');
  
  
// Get new sizes
  
list($width$height) = getimagesize($filename);
  
$ratio = ($height/$width);
  
$newHeight $thumbHeight;
  
$newWidth = ($thumbHeight/$ratio);
  
  
// Load
  
$thumb imagecreatetruecolor($newWidth$newHeight);
  
$source imagecreatefromjpeg($filename);  // Line 62
  
  // Resize
  
imagecopyresized($thumb$source0000$newWidth$newHeight$width$height);
  
  
// Output
  
imagejpg($thumb$thumbDir100);


So... How do I resolve this problem?

delayedinsanity 10-22-2009 06:09 AM

How big is the file you're trying to resize? You may have to up your memory limit in PHP, 32mb wouldn't hurt anyways, and in this case it's only asking for 2kb more, so it would definitely be the quick fix.

Aaron 10-22-2009 06:16 AM

ini_set did the trick. Thanks man.


All times are GMT. The time now is 03:52 AM.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0