Возникла такая проблема. При попытке создать изображение на основе существующего (копирование графического файла с уменьшением его размера) приводит к ошибке:
PHP Fatal error: Allowed memory size of 8388608 bytes exhausted (tried to allocate 11316 bytes).
Насколько я понял - это нехватка памяти для обработки файла и в результате PHP выдает ошибку.
Вот код функции:
CODE:
Function CreateImage($filename, $image)
{
$array = getimagesize($filename);
$newwidth = 200;
$newheight = 200;
$i = imagecreatetruecolor($newwidth, $newheight);
$source = imagecreatefromjpeg($filename);
imagecopyresized($i, $source, 0, 0, 0, 0, $newwidth, $newheight, $array[0], $array[1]);
imagejpeg($i, $image);
imagedestroy($i);
return $image;
}
Function CreateImage($filename, $image)
{
$array = getimagesize($filename);
$newwidth = 200;
$newheight = 200;
$i = imagecreatetruecolor($newwidth, $newheight);
$source = imagecreatefromjpeg($filename);
imagecopyresized($i, $source, 0, 0, 0, 0, $newwidth, $newheight, $array[0], $array[1]);
imagejpeg($i, $image);
imagedestroy($i);
return $image;
}
Можно ли как-то избавится от этой ошибки? Если можно, то как?