我在使用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;

关于php - CodeIgniter中的图像处理,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/255571/

10-09 22:28