之前从未遇到过这个......
我正在上传2个文件,一个是371kb,另一个是291kb。
public function useImage($image, $photoid){
$source = $image['tmp_name'];
$target = "projectimages/";
//prepare the largest image
$targetname = $photoid."large.jpg";
$file = $target . $targetname;
copy($source, $file);
list($width, $height) = getimagesize($file);
$modwidth = 800;
$diff = $width / $modwidth;
$modheight = $height / $diff;
$tn = imagecreatetruecolor($modwidth, $modheight);
$image = imagecreatefromjpeg($file);
imagecopyresampled($tn, $image, 0, 0, 0, 0, $modwidth, $modheight, $width, $height);
imagejpeg($tn, $file, 100);
//prepare the smaller image
$targetname = $photoid."small.jpg";
$file = $target.$targetname;
move_uploaded_file($source, $file);
list($width, $height) = getimagesize($file);
$modwidth = 400;
$diff = $width / $modwidth;
$modheight = $height / $diff;
$tn = imagecreatetruecolor($modwidth, $modheight);
$image = imagecreatefromjpeg($file);
imagecopyresampled($tn, $image, 0, 0, 0, 0, $modwidth, $modheight, $width, $height);
imagejpeg($tn, $file, 100);
}
我使用此函数调整它们的大小以使它们变小,为每个图像运行该函数。
当到达该功能的较小图像部分时,照片没有调整大小,而是弹出错误说:
Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 10368 bytes) in /Applications/MAMP/htdocs/bs/classes/image.php on line 202
这就是这一行:
$image = imagecreatefromjpeg($file);
这些小图片如何耗尽所有记忆?
感谢。
答案 0 :(得分:0)
例如:px中的宽度* px中的高度*颜色深度位...