Hi, next prob:
I have to create image preview files using imagecreatetruecolor (imagecreate)and imagecopyresampled (imagecopyresized).
I receive the error message:
Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 8192 bytes)
Is there any way to enable the IDE (or the PHP listener or anything else) to allocate more memory?
Here's the code of my converting function:
Code:
function PhotoGetPreview($phoId, $suffix, $thumbWidth = 150, $thumbHeight = 100)
{
$photoFile = PHOTO_PATH . $phoId . "_." . $suffix;
if(file_exists($photoFile))
{
$size = getimagesize($photoFile);
$width = $size[0];
$height = $size[1];
$ratioThumb = $thumbWidth / $thumbHeight;
$ratioPhoto = $width / $height;
if($ratioThumb <= 1)
{
if($ratioPhoto > 1)
$thumbHeight = intval($height * $thumbWidth / $width);
else
$thumbWidth = intval($width * $thumbHeight / $height);
}
else
{
if($ratioPhoto > 1)
$thumbWidth = intval($width * $thumbHeight / $height);
else
$thumbHeight = intval($height * $thumbWidth / $width);
}
$thumbFile = PHOTO_PATH . $phoId . "_thumb_" . $thumbWidth . "x" . $thumbHeight . "." . $suffix;
if(!file_exists($thumbFile))
{
define("GIF", 1);
define("JPG", 2);
define("PNG", 3);
$type = $size[2];
switch($type)
{
case GIF:
$oldPhoto = imagecreatefromgif($photoFile);
break;
case JPG:
$oldPhoto = imagecreatefromjpeg($photoFile);
break;
case PNG:
$oldPhoto = imagecreatefrompng($photoFile);
break;
default:
return false;
}
$newPhoto = imagecreatetruecolor($thumbWidth, $thumbHeight);
imagecopyresized($newPhoto, $oldPhoto, 0, 0, 0, 0, $thumbWidth, $thumbHeight, $width, $height);
imagedestroy($oldPhoto);
switch($type)
{
case GIF:
imagegif($newPhoto, $thumbFile);
case JPG:
imagejpeg($newPhoto, $thumbFile);
case PNG:
imagepng($newPhoto, $thumbFile);
}
imagedestroy($newPhoto);
}
}
return $thumbFile;
}