When trying to resize photographs I am getting the following error on my test server.

Fatal error: Allowed memory size of 8388608 bytes exhausted (tried to allocate 11520 bytes) in C:\wamp\www\phototest\reqfiles\submit_photo.req.php on line 70

here is my code from line 67 to 74

$src = ImageCreateFromJpeg($image);
$dst = ImageCreate($tn_width,$tn_height);
ImageCopyResized($dst, $src, 0, 0, 0, 0,
header("Content-type: image/jpeg");
ImageJpeg($dst, null, -1);

Can anyone help? is it a problem with my code or with my server?

9 Years
Discussion Span
Last Post by zAndrew

The quick and easy answer is that you need to figure out a different way to code that section as this shouldn't happen when you're working through your scripts.

However, often times you can fix this with a simple:

ini_set('memory_set', '16M')

On a more permanent basis, you could also increase the value of memory_set in your php.ini file, thus making the change for all of your scripts.

Again though, this just means that PHP (for some reason or another) is trying to allocate too much memory for the script it's executing. Sometimes it's not your fault if you use something like GD, since it loads all of it's information into memory.

Hope this explains.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.