嗨,根据 ci 文档,您可以使用 image_lib 调整图像大小,并且有一些选项建议我们可以从该图像创建额外的缩略图
create_thumb FALSE TRUE/FALSE (boolean) Tells the image processing function to create a thumb. R
thumb_marker _thumb None Specifies the thumbnail indicator. It will be inserted just before the file extension, so mypic.jpg would become mypic_thumb.jpg R
所以这是我的代码
$config_manip = array(
'image_library' => 'gd2',
'source_image' => "./uploads/avatar/tmp/{$this->input->post('new_val')}",
'new_image' => "./uploads/avatar/{$this->input->post('new_val')}",
'maintain_ratio'=> TRUE ,
'create_thumb' => TRUE ,
'thumb_marker' => '_thumb' ,
'width' => 150,
'height' => 150
);
$this->load->library('image_lib', $config_manip);
$this->image_lib->resize();
我会假设这段代码调整了我的图像大小并创建了一个缩略图,但我只得到一个具有指定尺寸和 _tump 后缀的图像
我也尝试添加此代码以手动创建第二张图片,但仍然无法正常工作,我只得到一张图片
$this->image_lib->clear();
$config_manip['new_image'] =
"./uploads/avatar/thumbnail_{$this->input->post('new_val')}";
$config_manip['width'] = 30 ;
$config_manip['height'] = 30 ;
$this->load->library('image_lib', $config_manip);
$this->image_lib->resize();