功能:
function do_upload() {
$config = array(
'allowed_types' => 'jpg|jpeg|gif|png',
'upload_path' => $this->gallery_path,
'max_size' => 2000
);
$this->load->library('upload', $config);
$this->upload->do_upload();
$image_data = $this->upload->data();
$config = array(
'image_library' => 'gd2',
'source_image' => $image_data['full_path'],
'new_image' => $this->gallery_path . '/thumbs',
'maintain_ratio' => TRUE,
'width' => 150,
'height' => 267
);
$this->load->library('image_lib', $config);
if ( ! $this->image_lib->resize())
{
echo $this->image_lib->display_errors();
}
$this->image_lib->clear();
}
并给出一个白页,不要显示错误。 但如果我删除这一行,就可以了!
'maintain_ratio' => TRUE,
'width' => 150,
'height' => 26
答案 0 :(得分:0)
您的系统是否安装了gd2库?
日志文件中有什么内容吗?
答案 1 :(得分:0)
问题是因为你没有 create_thumb = TRUE
尝试以这种方式形成阵列。它更干净,没有错误。
public function resize($path, $file){
$config['image_library'] = 'gd2';
$config['source_image'] = $path;
$config['create_thumb'] = TRUE;
$config['maintain_ratio'] = TRUE;
$config['width'] = 280;
$config['height'] = 165;
$config['new_image'] = './uploads/'.$file;
$this->load->library('image_lib', $config);
$this->image_lib->resize();
}