2013-06-04 1 views
8

이미지 업로드를 완료했으며 CI에서 여러 번 크기가 조정되었습니다. 동일한 코드가 한 페이지에서 작동하지만 다른 페이지에서는 작동하지 않습니다. "이 서버는이 유형의 이미지를 처리하는 데 필요한 GD 기능을 지원하지 않습니다."라는 오류 메시지가 표시됩니다. 이미지를 업로드 할 수있는 코드는 이해할 수없는 내가 무슨 일귀하의 서버가이 유형의 이미지를 처리하는 데 필요한 GD 기능을 지원하지 않습니다 .Cy

function do_upload() { 

     $original_path = './uploads/activity_images/original'; 
     $resized_path = './uploads/activity_images/resized'; 
     $thumbs_path = './uploads/activity_images/thumb'; 
     $this->load->library('image_lib'); 

     $config = array(
      'allowed_types' => 'jpg|jpeg|gif|png', //only accept these file types 
      'max_size' => 2048, //2MB max 
      'upload_path' => $original_path //upload directory  
     ); 
     $this->load->library('upload', $config); 
     $this->upload->do_upload(); 
     $image_data = $this->upload->data(); //upload the image 
     $image1 = $image_data['file_name']; 

     //your desired config for the resize() function 
     $config = array(
      'source_image' => $image_data['full_path'], //path to the uploaded image 
      'new_image' => $resized_path, 
      'maintain_ratio' => true, 
      'width' => 128, 
      'height' => 128 
     ); 
     $this->image_lib->initialize($config); 
     $this->image_lib->resize(); 

     // for the Thumbnail image 
     $config = array(
      'source_image' => $image_data['full_path'], 
      'new_image' => $thumbs_path, 
      'maintain_ratio' => true, 
      'width' => 36, 
      'height' => 36 
     ); 
     //here is the second thumbnail, notice the call for the initialize() function again 
     $this->image_lib->initialize($config); 

     $this->image_lib->resize(); 
     //$this->image_lib->clear(); 
     echo $this->image_lib->display_errors(); 
     var_dump(gd_info()); 
     die(); 
     return $image1; 
    } 

\ ...입니다 .. ??

$original_path = './uploads/activity_images/original'; 
$resized_path = './uploads/activity_images/resized'; 
$thumbs_path = './uploads/activity_images/thumb'; 
$this->load->library('image_lib'); 

에 :

+0

설치 무엇 'var_dump (gd_info());'는 당신에게 무엇을 제공합니까? –

+0

array 'GD Version'=> 문자열 '번들 (2.0.34 호환)'(길이 = 27) 'FreeType Support'=> 부울 true 'FreeType Linkage'=> 'freetype'(길이 = 13) 'T1Lib 지원'=> 부울 거짓 'GIF 읽기 지원'=> 부울 사실 'GIF 지원 만들기'=> 부울 사실 'JPEG 지원'=> 부울 사실 'PNG 지원'=> 부울 사실 'WBMP 지원 '=> 부울 참 true 'XPM Support '=> 부울 거짓 'XBM Support '=> 부울 참 true 'JIS 매핑 일본 글꼴 지원 '=> 부울 거짓 – Drudge

+0

또한'$ config ['image_library '] = 'gd2'; –

답변

4
은 첫 번째 라인을 변경

$config['image_library'] = 'gd2'; 
$original_path = './uploads/activity_images/original'; 
$resized_path = './uploads/activity_images/resized'; 
$thumbs_path = './uploads/activity_images/thumb'; 
$this->load->library('image_lib', $config); 
+1

나는 입력 필드를 로 바꾼다. ... – Drudge

+0

흠. 좋아요, 고쳐 주셨으면합니다. –

+3

유효한 이미지 파일의 전체 경로를 제공하지 않으면 CI가이 오류를 발생시키는 것을 직접 발견했습니다. 예를 들어 파일 이름이 누락 된 경우 getimagesize()는 false를 반환하고 오류가 발생합니다. 매우 명확하지 ... – stef

11

을 나는 비슷한 문제에 직면 내 프로젝트 중. 이 link이 문제를 해결하는 데 도움이됩니다. 아무것도 (내 경우) 작동하지 않는 경우

$this->load->library('image_lib'); 
// Set your config up 
$this->image_lib->initialize($config); 
// Do your manipulation 
$this->image_lib->clear(); 
+0

+1이 솔루션은 나를 위해 일했습니다. –

+0

도 CI 3을 사용하여 저에게 적합합니다. –

-1

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

교체, 오류가 실제로 전체 문제가 될 수 있습니다. 설치 GD 경우

  1. 확인, 리눅스에 설치

    sudo는 냠 목록을 할 것 | 그렙 PHP는

    설치되어 있지 않은 경우
  2. 설치, 그것은

    sudo는 냠 PHP-GD-패키지 이름

  3. RESTART 아파치

    sudo는 서비스 아파치를 다시 시작

관련 문제