2017-04-27 1 views
0

내 웹 사이트에 큰 이미지를 업로드하고 싶습니다. 나는 codeigniter를 사용하는 사람들의 크기를 줄이고 싶다. 따라서이 코드를 수행하고 있습니다.Codeigniter 이미지 압축이 작동하지 않습니다.

function upload_image($data) { 
    $config['upload_path'] = './temp/'; 
    $config['allowed_types'] = 'gif|jpg|png'; 
    $config['max_size'] = 10000; 
    $this->load->library('upload', $config); 
    if (!$this->upload->do_upload('image')) { 
     $error = array('error' => $this->upload->display_errors()); 
     pre($error); 
    } else { 
     $config = array(); 
     $data = array('upload_data' => $this->upload->data()); 
     $config['image_library'] = 'gd'; 
     $config['source_image'] = './temp/' . $data['upload_data']['file_name']; 
     $config['create_thumb'] = FALSE; 
     $config['maintain_ratio'] = TRUE; 
     $config['quality'] = 50; 
     $config['new_image'] = './temp/' . $data['upload_data']['file_name']; 
     $this->load->library('image_lib', $config); 
     $this->image_lib->resize(); 

     pre($data); 
    } 
} 

이미지가 압축되지 않습니다. 원본 및 업로드 된 크기는 동일합니다. 내가 어디서 잘못한거야?

+1

사용 품질 PARAM이 매개 변수를 다음 이미지 $의 구성 [의 크기를 줄일 것 ' 너비 '] = 75; $ config [ 'height'] = 50; –

답변

0

오류가있을 수 있습니다. 오류를 확인합니다 :

if (!$this->image_lib->resize()){ 
    echo $this->image_lib->display_errors(); 
} 

참고 : 사용 GD2가 라이브러리로 (기본값은 GD2됩니다) :

$config['image_library'] = 'gd2'; 
관련 문제