php裁剪图片时占用内存超过12M~~急,在线等

来源:百度知道 编辑:UC知道 时间:2024/05/30 03:58:18
代码太长,不能全部贴出,以下是出错的代码
//缩放图片
function resize($width, $height, $percent=0)
{
if(!is_resource($this->_img)) return false;
if(empty($width) && empty($height)){
if(empty($percent)) return false;
else{
$width = round($this->_width * $percent);
$height = round($this->_height * $percent);
}
}elseif(empty($width) && !empty($height)){
$width = round($height * $this->_width / $this->_height );
}else{
$height = round($width * $this->_height / $this->_width);
}
$tmpimg = imagecreatetruecolor($width,$height);
if(function_exists('imagecopyresampled')) imagecopyresampled($tmpimg, $this->_img, 0, 0, 0, 0, $width, $height, $this->_width, $this->_height);
else imagecopyresized($tmpimg, $this->_img, 0, 0, 0, 0, $width, $height, $this->_width, $this->_height);
$this->destroy();
$this->_img = $tmpimg;
$thi

一、修改php.ini(推荐)
memory_limit = 12M
二、在程序里面添加如下语句
ini_set(''memory_limit'', ''12M'');

解决办法(三种):
一、修改php.ini(推荐)
memory_limit = 12M
二、在程序里面添加如下语句
ini_set(''memory_limit'', ''12M'');
三、在根目录建立.htaccess文件,添加如下内容
php_value memory_limit 12M
如果还不能解决,就把它改得再大一些。

在php的配置文件php.ini中应该可以制定最大内存,写大点应该就行了
大概是memory_limit

在那个php.ini文件当中,把那个内存修改大一些就行啦~~
你找到
memory_limit =

然后把内存修改足够大就行了~~~

你可以先试试看,不行再说~~~

学习中