图片处理类,不能处理多个图片
怎样才能做到,处理多个图片.或者是处理同一个图片2次以上
比如一个图片,我要生成两个不同大小的图片.应该怎么做??
实在没办法了.帮帮忙.....:dizzy: 第一次用$this->load->library('image_lib', $config);
第二次用$this->image_lib->initialize($config2); 我写成函数了...
//切图
function _Slicing($width,$height,$image,$Newimage,$Thumb=TRUE){
$config['image_library'] = 'gd2';
$config['source_image'] = $image;
$config['new_image'] = $Newimage;
$config['create_thumb'] = $Thumb;
$config['maintain_ratio'] = FALSE;
$config['width'] = $width;
$config['height'] =$height;
$this->load->library('image_lib', $config);
if ( !$this->image_lib->resize()){
$this->image_lib->clear();
return $this->image_lib->display_errors();
}
else{
$this->image_lib->clear();
return true;
}
} 注意,->load->library()只能用一次,第二次再用load,$config不会改变,相当于你进行了两次相同的操作,第一个图片被第二个覆盖了 谢谢老大.问题解决了... 红色部分老大提醒的是.这样就没问题了...这个初始化.
function _Slicing($width,$height,$imagePath,$NewPath){
$config['image_library'] = 'gd2';
$config['source_image'] =$imagePath;
$config['new_image'] =$NewPath;
$config['create_thumb'] = FALSE;
$config['maintain_ratio'] = FALSE;
$config['width'] = $width;
$config['height'] =$height;
$this->load->library('image_lib', $config);
$this->image_lib->initialize($config);
if ( !$this->image_lib->resize()){
return $this->image_lib->display_errors();
}
else{
$this->image_lib->clear() ;
return ture;
}
} 多文件上传类,论坛有,自己搜一下。 收藏了,遇到这个功能以后直接用,哈哈!
页:
[1]