用户
 找回密码
 入住 CI 中国社区
搜索
查看: 2838|回复: 3
收起左侧

[HELP] 先执行缩略图再加水印,只缩略了,没有加水印

[复制链接]
发表于 2011-11-30 12:31:06 | 显示全部楼层 |阅读模式
本帖最后由 S┢┦éé卪√ 于 2011-11-30 12:33 编辑
PHP复制代码
 
  //生成缩略图
   $config['source_image'] = $full_path;
   $config['width'] = 220;
   $config['height'] = 160;
   $config['quality'] = 90;
   $new_image = 'W0'.date('YmdHis').rand(10000, 99999).$file_ext;
   $config['new_image'] = $file_path.$new_image;
   $this->load->library('image_lib', $config);
   $this->image_lib->resize();
   unlink($full_path);
   $this->image_lib->clear();
   
   //添加水印
   $config['source_image'] = $file_path.$new_image;
   $config['wm_text'] = 'Copyright 2006 - John Doe';
   $config['wm_type'] = 'text';
//   $config['wm_font_path'] = './system/fonts/texb.ttf';
   $config['wm_font_size'] = '16';
   $config['wm_font_color'] = '000000';
   $config['wm_vrt_alignment'] = 'bottom';
   $config['wm_hor_alignment'] = 'center';
   $config['wm_padding'] = '20';
   $this->image_lib->initialize($config);
   $this->image_lib->watermark();
 
复制代码


想要达到的效果:生成缩略图,并且在缩略图上面添加水印
现在执行结果:生成了缩略图,缩略图上面没有水印。。

求帮助。。
 楼主| 发表于 2011-11-30 15:14:56 | 显示全部楼层
自行解决了。。
贴代码分享下。。
PHP复制代码
//生成缩略图
                  $this->load->library('image_lib');
                        $config['source_image'] = $full_path;
                        $config['width'] = 220;
                        $config['height'] = 160;
                        $config['quality'] = 90;
                        $new_image = 'W0'.date('YmdHis').rand(10000, 99999).$file_ext;
                        $config['new_image'] = $file_path.$new_image;
                        $this->image_lib->initialize($config);
                        if (!$this->image_lib->resize())
                        {    
                                echo $this->image_lib->display_errors();
                        }
                        unlink($full_path);
                        unset($config);
                        $this->image_lib->clear();
                       
                        //添加水印
                        $config['source_image'] = $file_path.$new_image;
                        $config['wm_text'] = 'Copyright2006';
                        $config['wm_type'] = 'text';
//                      $config['wm_font_path'] = './system/fonts/texb.ttf';
                        $config['wm_font_size'] = '14';
                        $config['wm_font_color'] = '000000';
                        $config['wm_vrt_alignment'] = 'bottom';
                        $config['wm_hor_alignment'] = 'center';
                        $config['wm_padding'] = '0';
                        $this->image_lib->initialize($config);
                        $this->image_lib->watermark();
                        if (!$this->image_lib->watermark())
                        {    
                                echo $this->image_lib->display_errors();
                        }
                        unset($config);
                        $this->image_lib->clear();
复制代码
发表于 2011-12-1 07:59:26 | 显示全部楼层
留个纪念
发表于 2013-4-3 23:59:57 | 显示全部楼层

留个纪念

本版积分规则