TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 10-22-2009, 05:58 AM   #1 (permalink)
The Frequenter
 
Join Date: Dec 2007
Location: In my basement
Posts: 386
Thanks: 47
Aaron is on a distinguished road
Default 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?
__________________
Signatures are nothing but incriminating.
Send a message via MSN to Aaron
Aaron is offline  
Reply With Quote
Old 10-22-2009, 06:09 AM   #2 (permalink)
is cute and cuddly
 
delayedinsanity's Avatar
 
Join Date: Mar 2008
Location: Vegas, Baby
Posts: 963
Thanks: 31
delayedinsanity is on a distinguished road
Default

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.
delayedinsanity is offline  
Reply With Quote
The Following User Says Thank You to delayedinsanity For This Useful Post:
Aaron (10-22-2009)
Old 10-22-2009, 06:16 AM   #3 (permalink)
The Frequenter
 
Join Date: Dec 2007
Location: In my basement
Posts: 386
Thanks: 47
Aaron is on a distinguished road
Default

ini_set did the trick. Thanks man.
__________________
Signatures are nothing but incriminating.
Send a message via MSN to Aaron
Aaron is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
pass by reference allworknoplay Absolute Beginners 33 05-08-2009 10:41 AM
virtual memory leak shiggle Absolute Beginners 2 02-26-2008 08:55 AM
Firefox slowness caused by memory fragmentation Wildhoney General 22 12-09-2007 04:36 PM
Memory Management with Declare Wildhoney Advanced PHP Programming 2 10-18-2007 03:44 PM
Method to check Size of Remote File alex.zeal Tips & Tricks 4 09-22-2007 10:22 AM


All times are GMT. The time now is 02:19 PM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design