Satal Keto
11-19-2007, 04:48 PM
Hello I am trying to get some code which will resize images which are uploaded to my website using a form.
The code I am using to resize the images atm is
function createThumbnail($imageDirectory, $imageName, $thumbDirectory, $thumbHeight)
{
$srcImg = imagecreatefromjpeg("$imageDirectory/$imageName");
$origWidth = imagesx($srcImg);
$origHeight = imagesy($srcImg);
$ratio = $origHeight / $thumbHeight;
$thumbWidth = $origWidth / $ratio;
$dst_img=ImageCreateTrueColor($thumbWidth,$thumbHeight);
#imagecopyresampled($dst_img,$srcImg,0,0,0,0,$thumbWidth,$thumbHeight,$origWidth,$origHeight);
imagecopyresized($dst_img,$srcImg,0,0,0,0,$thumbWidth,$thumbHeight,$origWidth,$origHeight);
imagejpeg($dst_img,$thumbDirectory . "/" . $imageName);
imagedestroy($dst_img);
}
The problem is when ever I try to run this code it is saying...
Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 3264 bytes) in K:\WOS Stuff\www\sb\adminPhotos.php on line 5where line 5 is $srcImg = imagecreatefromjpeg("$imageDirectory/$imageName");
I was wondering whether anyone had any idea's of some how that I would be able to resize the images without causing this error?
The code I am using to resize the images atm is
function createThumbnail($imageDirectory, $imageName, $thumbDirectory, $thumbHeight)
{
$srcImg = imagecreatefromjpeg("$imageDirectory/$imageName");
$origWidth = imagesx($srcImg);
$origHeight = imagesy($srcImg);
$ratio = $origHeight / $thumbHeight;
$thumbWidth = $origWidth / $ratio;
$dst_img=ImageCreateTrueColor($thumbWidth,$thumbHeight);
#imagecopyresampled($dst_img,$srcImg,0,0,0,0,$thumbWidth,$thumbHeight,$origWidth,$origHeight);
imagecopyresized($dst_img,$srcImg,0,0,0,0,$thumbWidth,$thumbHeight,$origWidth,$origHeight);
imagejpeg($dst_img,$thumbDirectory . "/" . $imageName);
imagedestroy($dst_img);
}
The problem is when ever I try to run this code it is saying...
Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 3264 bytes) in K:\WOS Stuff\www\sb\adminPhotos.php on line 5where line 5 is $srcImg = imagecreatefromjpeg("$imageDirectory/$imageName");
I was wondering whether anyone had any idea's of some how that I would be able to resize the images without causing this error?