1
我想创建上传的图像的缩略图,然后调整上传的图像的大小。 这是我的代码:CodeIgniter调整上传的图像不起作用
$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();
}
缩略图创建就好了,但originial图像的大小调整是行不通的。我在这里错过了什么?
编辑:我曾尝试添加的行:
$this->image_lib->clear();
两个图像之间的操作。
+1这里发布自己的解决方案! – swatkins