2010-03-09 104 views
0

功能:CodeIgniter的調整大小()的問題

function do_upload() { 

    $config = array(
     'allowed_types' => 'jpg|jpeg|gif|png', 
     'upload_path' => $this->gallery_path, 
     'max_size' => 2000 
    ); 

    $this->load->library('upload', $config); 
    $this->upload->do_upload(); 
    $image_data = $this->upload->data(); 


    $config = array( 
     'image_library' => 'gd2', 
     'source_image' => $image_data['full_path'], 
     'new_image' => $this->gallery_path . '/thumbs', 
     'maintain_ratio' => TRUE, 
     'width' => 150, 
     'height' => 267 
    ); 

    $this->load->library('image_lib', $config); 
    if (! $this->image_lib->resize()) 
    { 
     echo $this->image_lib->display_errors(); 
    } 
    $this->image_lib->clear(); 

} 

並給出了一個白色的頁面,不顯示錯誤。 但是,如果我擦除這條線,工作正常!

'maintain_ratio' => TRUE, 
'width' => 150, 
'height' => 26 

回答

0

您的系統是否安裝了gd2庫?

日誌文件中是否有任何內容?

+0

問題是,我使用的圖像是擴展名爲.JPG的大寫字母。 – Mango 2010-03-10 20:54:16

0

問題,是因爲你沒有create_thumb = TRUE

嘗試形成陣列的這種方式。它更乾淨,沒有錯誤。

public function resize($path, $file){ 
     $config['image_library'] = 'gd2'; 
     $config['source_image'] = $path; 
     $config['create_thumb'] = TRUE; 
     $config['maintain_ratio'] = TRUE; 
     $config['width'] = 280; 
     $config['height'] = 165; 
     $config['new_image'] = './uploads/'.$file; 

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