嗨朋友我正在尝试使用codeigniters resize image_lib ..而且我无法使用这个调整图像大小。请帮我解决这个问题
错误:
使用gd: 图像的路径不正确。您的服务器不支持处理此类图像所需的GD功能。
使用ImageMagick: 图像的路径不正确。图像库的路径不正确。请在图像首选项中设置正确的路径。
代码:
$this->load->library('upload');
$config['upload_path'] = $path;
$config['file_name'] = $file_name;
$config['allowed_types'] = 'jpg|png';
$config['overwrite'] = false;
$this->upload->initialize($config);
if ( ! $this->upload->do_upload())
{
return false;
}
else{
$this->load->library('image_lib');
$resize['image_library'] = 'gd2';
$resize['source_image'] = $path.$file_name;
$resize['maintain_ratio'] = FALSE;
$resize['width'] = 40;
$resize['height'] = 40;
$resize['quality'] = 100;
// print_r($path.$file_name);
// Here the path of the image is assets/Data/adv_images/2/2-537f2a3651300
// which is absolutely right also tried base_url().$path.$file_name
$this->image_lib->initialize($resize);
if ( ! $this->image_lib->resize()){
echo $this->image_lib->display_errors();
}
return true;
}
答案 0 :(得分:0)
尝试通过这种方式设置路径:
$resize['source_image'] = $this->upload->data()['full_path'];