我想创建上传图像的缩略图,然后调整上传图像的大小。这是我的代码:
$data = array('upload_data' => $this->upload->data());
$upload_data = $data['upload_data'];
//Create image thumbnail
$config['image_library'] = 'gd2';
$config['source_image'] = $upload_data['full_path'];
$config['create_thumb'] = TRUE;
$config['overwrite'] = TRUE;
$config['maintain_ratio'] = TRUE;
$config['width'] = 150;
$config['height'] = 150;
$this->load->library('image_lib', $config);
$this->image_lib->resize();
//Resize original image for space saving purposes
if ($upload_data['image_width'] > 850 || $upload_data['image_height'] > 850) {
$config['image_library'] = 'gd2';
$config['source_image'] = $upload_data['full_path'];
$config['maintain_ratio'] = TRUE;
$config['create_thumb'] = FALSE;
$config['overwrite'] = TRUE;
$config['width'] = 850;
$config['height'] = 850;
$this->load->library('image_lib', $config);
$this->image_lib->resize();
}
缩略图创建得很好,但原始图像的大小调整不起作用。我在这里想念什么?
编辑:我尝试添加以下行:
$this->image_lib->clear();
在两个图像处理之间。