Thanks again for your suggestions ... here is some code and the output.
function resize($height = 300, $width = 400){
/** If array is not passed, use a variable */
$image = $this->path.$this->source['name'];
echo memory_get_usage().'<br />';
/** Create a blank image */
$resize = imagecreatetruecolor($width, $height);
echo memory_get_usage().'<br />';
$quality = 75;
$size = getimagesize($image);
switch ($size['mime']) {
case 'image/jpeg':
echo memory_get_usage().'<br />';
$im = imagecreatefromjpeg($image);
imagecopyresampled($resize, $im, 0, 0, 0, 0, $width, $height, $size[0], $size[1]); // Resample the original JPEG
imagejpeg($resize, $image, $quality); // Output the new JPEG
echo memory_get_usage().'<br />';
break;
case 'image/jpg':
$im = imagecreatefromjpeg($image);
imagecopyresampled($resize, $im, 0, 0, 0, 0, $width, $height, $size[0], $size[1]); // Resample the original JPEG
imagejpeg($resize, $image, $quality); // Output the new JPEG
break;
case 'image/png':
$im = imagecreatefrompng($image);
imagecopyresampled($resize, $im, 0, 0, 0, 0, $width, $height, $size[0], $size[1]); // Resample the original PNG
imagepng($resize, $image, $quality); // Output the new PNG
break;
}
imagedestroy($im);
return true;
}
That is obviously a function in my class, but it should suffice for the example usage of my code.
Here is the output of all of the calls to get_memory_usage before it dies:
436920
1046680
1047216
Fatal error: Allowed memory size of 8388608 bytes exhausted (tried to allocate 6400 bytes) in /home/xxxxx/public_html/xxxxx-xxxxx/xxxxx/classes/Image.php on line 116
Unfortunately, I cannot attch the image I am using as it is greater than the thread allows. It is 342KB. Should I post more code or is this enough to shed some light on what's going on?
Thanks again.