2011-06-16 48 views
1

我有下面的代碼,如果我不使用水印它很好,但是當我使用水印時,原始圖片和縮略圖變得非常小,水印發生在縮略圖上,我想水印在原始圖像上,請幫助codeigniter thumbnail created但原始圖像問題

//UPLOAD IMAGE 
     //some $config vars for image 
     $config['upload_path'] = './images/blog'; 
     $config['allowed_types'] = 'gif|jpg|jpeg|png'; 
     $config['max_size'] = '0'; 
     $config['remove_spaces'] = true; 
      $config['overwrite'] = false; 
      $config['max_width'] = '0'; 
      $config['max_height'] = '0'; 

      $this->load->library('upload', $config); 

      //upload main image 
      if(!$this->upload->do_upload('photo')){ 
       $e = $this->upload->display_errors(); 
       print_r($e); 
      } 

      $image = $this->upload->data(); 


    //thumbnail creation start 
      $config1['image_library'] = 'gd2'; 
      $config1['source_image'] = $image['full_path']; 
      $config1['create_thumb'] = TRUE; 
      $config1['maintain_ratio'] = TRUE; 
      $config1['width'] = 75; 
      $config1['height'] = 50; 

      $this->load->library('image_lib', $config1); 
      $this->image_lib->resize(); 
      //thumbnail creation ends 


     $this->image_lib->clear(); 
     //$image = $this->upload->data(); 
     //start watermarking 
     $config2['source_image'] = $image['full_path']; 
     $config2['wm_text'] = 'Copyright 2011 myself'; 
     $config2['wm_type'] = 'text'; 
     $config2['wm_font_path'] = './system/fonts/FromWhereYouAre.ttf'; 
     $config2['wm_font_size'] = '16'; 
     $config2['wm_font_color'] = 'ffffff'; 
     $config2['wm_vrt_alignment'] = 'middle'; 
     $config2['wm_hor_alignment'] = 'center'; 
     $config2['wm_padding'] = '20'; 

     $this->load->library('image_lib'); 
     $this->image_lib->initialize($config); 
     $this->image_lib->watermark(); 
     //end watermarking 

回答

3

請嘗試在水印編碼追加

 $config2['new_image'] = '';