| 제목 | 이미지 썸네일 생성과 워터마크 문의 입니다. | ||
|---|---|---|---|
| 글쓴이 | 경상도곰남 | 작성시각 | 2013/12/19 11:26:55 | 
| 
                         | 
                |||
| 
                         여러개의 이미지를 첨부할 때 이미지 마다 워터마크를 찍고 썸네일을 생성 할려고 합니다. 
    //upload 설정
   $this->load->library('upload');
   $this->load->library('image_lib');
   $config = array(
    'upload_path' => FILE_UPLOAD_PATH . 'car/'.$car_no."/",
    'allowed_types' => 'gif|jpg|png',
    'encrypt_name' => TRUE,
    'max_size' => '10240'
   );
   $cnt = 0;
 
   foreach($_FILES as $field => $file)
   { 
    if(!empty($file['name']))
    {
     $this->upload->initialize($config);
     
     if(!$this->upload->do_upload($field))
     { 
      $errors = $this->upload->display_errors();
      echo $errors;
      exit;
     }
     else
     {
      $data = $this->upload->data();
      if($field != "accident_filenm")
      {
       
       if($data["is_image"] == 1 && $data["image_width"] > 170)
       {      
        $config_thumb = array();
        $config_thumb['image_library'] = 'gd2';
        $config_thumb['source_image'] = $data['full_path'];
        $config_thumb['create_thumb'] = TRUE;
        $config_thumb['maintain_ratio'] = TRUE;
        $config_thumb['master_dim'] = 'width';
        $config_thumb['quality'] = 75;
        $config_thumb['width'] = 170;
        $config_thumb['height'] = 130;
        $this->image_lib->initialize($config_thumb);
        
        //$this->load->library('image_lib', $config_thumb);
        $this->image_lib->resize();
        $this->image_lib->clear(); 
        $data['thumb_filenm'] = $data["raw_name"] . "_thumb" . $data["file_ext"];
        $data['ci_cd'] = $ci_cd[$cnt];       
        
       }
       else
       {
        $data['thumb_filenm'] = "";
       }
       
       
       $config_wmark = array();
       $config_wmark['image_library'] = 'gd2';       
       $config_wmark['source_image']  =  $data['full_path'];
       $config_wmark['wm_overlay_path'] = WEB_PUBLIC_PATH .'img/watermark.png';
       $config_wmark['new_image'] = $data["raw_name"] . "_wmark" . $data["file_ext"];
       $config_wmark['wm_type'] = 'overlay';
       $config_wmark['wm_opacity'] = '10';
       $config_wmark['wm_vrt_alignment'] = 'bottom';
       $config_wmark['wm_hor_alignment'] = 'right';
       $config_wmark['create_thumb'] = FALSE;
       $this->image_lib->initialize($config_wmark);        
       $this->image_lib->watermark();
       $this->image_lib->clear(); 
       $data['wmark_filenm'] = $data["raw_name"] . "_wmark" . $data["file_ext"];
       $upload_data[] = $data; 
      }
     }
    } 
    $cnt++;
   }
                        
                     | 
                |||
| 다음글 | CI에서 mysql 함수사용 (2) | ||
| 이전글 | 컨트롤러에서 컨트롤러 호출 (2) | ||
| 
                             
                                taegon
                                /
                                2013/12/19 17:51:24 /
                                추천
                                0
                             
                             | 
                    
| 
                             
                                경상도곰남
                                /
                                2013/12/20 11:22:44 /
                                추천
                                0
                             
                            답변 감사 합니다.  | 
                    
$config_wmark['new_image'] =$data["raw_name"] ."_wmark".$data["file_ext"];
에서 경로를 주시고 생성해 보시죠?
저 소스대로 한다면 워터마크 새겨진 이미지 생성이 index.php 경로에 생성되셨을 것 같은데요?..