|
PHP复制代码 $this->load->library('image_lib');
//添加水印
$config['source_image'] =$this->config->item('photo_path').$ImgName;
$config['wm_type'] = 'overlay';
$config['quality'] = 100;
$config['wm_overlay_path']='upload/shui.png';
$config['wm_vrt_alignment'] = 'middle';
$config['wm_hor_alignment'] = 'center';
$this->image_lib->initialize($config);
if(!$this->image_lib->watermark()){
echo $this->image_lib->display_errors();
}
$this->image_lib->clear();
//生成缩略图
$config['image_library'] = 'gd2';
$config['source_image'] = $this->config->item('photo_path').$ImgName;
$config['create_thumb'] = TRUE;
$config['maintain_ratio'] = TRUE;
$config['width'] = $this->config->item('photo_width');
$config['height'] = $this->config->item('photo_height');
$config['new_image'] = $this->config->item('photo_path').$ImgRawName."_thumb".$ImgType;
$this->image_lib->initialize($config);
$this->image_lib->resize()
复制代码
注意的两点,水印打完,需要initialize,缩略图的时候,设置new_image,这样才不会把打了水印的原图给覆盖!
|
|