Php CodeIgniter中的图像处理

Php CodeIgniter中的图像处理,php,codeigniter,Php,Codeigniter,我在使用CodeIgniter 1.7处理图像时遇到一些问题。使用以下代码,图像将正确上载。唉,不是制作新的图像,然后修改;现有图像将被修改。有什么帮助吗 //Upload image first $config['upload_path'] = './uploads/'; $config['allowed_types'] = 'gif|jpg|png|bmp'; $this->load->library('upload', $config); $this->

我在使用CodeIgniter 1.7处理图像时遇到一些问题。使用以下代码,图像将正确上载。唉,不是制作新的图像,然后修改;现有图像将被修改。有什么帮助吗

//Upload image first
$config['upload_path'] = './uploads/';
$config['allowed_types'] = 'gif|jpg|png|bmp';

$this->load->library('upload', $config);        
$this->upload->do_upload();

//Now fix the image
$picloc = $this->upload->data();
$picloc = $picloc['file_name'];

$thumbnail = "thumb_".$picloc;

$imagemanip['image_library'] = 'gd2';
$imagemanip['source_image'] = './uploads/'.$picloc;
$imagemanip['new_img'] = './uploads/'.$thumbnail;
$imagemanip['maintain_ratio'] = TRUE;
$imagemanip['width'] = 250;
$imagemanip['height'] = 250;

$this->load->library('image_lib', $imagemanip);

$this->image_lib->resize();

问题很简单,您的行中有一个输入错误:

$imagemanip['new_img'] = './uploads/'.$thumbnail;
索引应该是“new_image”,而不是“new_img”,因此该行变为

$imagemanip['new_image'] = './uploads/'.$thumbnail;
现在这将完成你的工作

//Upload image first
$config['upload_path'] = './uploads/';
$config['allowed_types'] = 'gif|jpg|png|bmp';

$this->load->library('upload', $config);        
$this->upload->do_upload();

//Now fix the image
$picloc = $this->upload->data();
$picloc = $picloc['file_name'];

$thumbnail = "thumb_".$picloc;

$imagemanip['image_library'] = 'gd2';
$imagemanip['source_image'] = './uploads/'.$picloc;
$imagemanip['new_image'] = './uploads/'.$thumbnail;// this will get change in new code.
$imagemanip['maintain_ratio'] = TRUE;
$imagemanip['width'] = 250;
$imagemanip['height'] = 250;

$this->load->library('image_lib', $imagemanip);

$this->image_lib->resize();