我正在使用以下代码,但即使$this->image_lib->resize()
返回 true,也无法调整图像大小,不知道出了什么问题:
if(file_exists($_SERVER['DOCUMENT_ROOT']."/uploads/avatars/".str_replace('_','-',$image)))
{
$config['source_image'] = $_SERVER['DOCUMENT_ROOT']."/uploads/avatars/".str_replace('_','-',$image);
}
else if (!file_exists("./uploads/avatars/".$image) || $image=="")
{
$config['source_image'] = $_SERVER['DOCUMENT_ROOT'].'/uploads/avatars/photo.jpg';
}
else
{
$config['source_image'] = $_SERVER['DOCUMENT_ROOT']."/uploads/avatars/".$image;
}
$config['image_library'] = 'gd2';
$config['create_thumb'] = TRUE;
$config['maintain_ratio'] = TRUE;
$config['dynamic_output'] = TRUE;
$config['width'] = $width;
$config['height'] = $height;
$this->load->library('image_lib', $config);
$this->image_lib->resize();