我用php脚本上传图像,我希望能够改变图像的大小,如果图像太大,然后创建相同图像的拇指,现在我的图像是调整大小,但拇指没有创建出于某种原因…也没有错误。脚本如下:
if($image_data['image_width'] > 1024 || $image_data['image_height'] > 768)
{
$config_resize = array(
'source_image' => $image_data['full_path'],
'new_image' => "./uploads/",
'overwrite' => true,
'maintain_ratio' => true,
'width' => 1024,
'height' => 768
);
$this->load->library('image_lib', $config_resize);
if(! $this->image_lib->resize())
{
echo $this->image_lib->display_errors();
}
$config_thumb = array(
'source_image' => $config_resize['source_image'],
'new_image' => "./uploads/thumbs/",
'maintain_ratio' => true,
'width' => 150,
'height' => 100
);
$this->load->library('image_lib', $config_thumb);
if(! $this->image_lib->resize())
{
echo $this->image_lib->display_errors();
}
}
.....
.....
$config_thumb = array(
'source_image' => $config_resize['source_image'],
'new_image' => "./uploads/thumbs/",
'maintain_ratio' => true,
'width' => 150,
'height' => 100
);
$this->image_lib->initialize($config_thumb); // <--- !!!
和不要加载库两次