2011-08-01 21 views
0

Possible Duplicate:
CodeIgniter Image thumbnailing issue笨multipIe影像縮圖問題:

我要創建兩個縮略圖withh不同尺寸相同的圖像。在我的代碼中,只有第一個縮略圖代碼創建了 ,並且發生了以下錯誤。 錯誤:「您的服務器不支持處理此類圖像所需的GD功能。」

function createThumb1($imageName) //file name passed 
{ 


     // this thumbnail created 
    $config['image_library'] = 'gd2'; 
    echo $config['source_image'] = $_SERVER['DOCUMENT_ROOT'].'/uploads/'.$imageName; 

    $config['create_thumb'] = TRUE; 
    $config['maintain_ratio'] = false; 
    $config['width']  = 80; 
    $config['height'] = 80; 
    $config['new_image'] = $_SERVER['DOCUMENT_ROOT'].'/images/uploads/thumbs/'.$imageName; 
    $this->load->library('image_lib', $config); 
    if (! $this->image_lib->resize()){echo $this->image_lib->display_errors();} 

    $this->image_lib->clear(); 

    // unable to create this this thumbnail 
    $config['image_library'] = 'gd2'; 
    echo $config['source_image'] = $_SERVER['DOCUMENT_ROOT'].'/uploads/'.$imageName; 
    $config['create_thumb'] = FALSE; 
    $config['maintain_ratio'] = false; 
    $config['width']  = 696; 
    $config['height'] = 241; 
    $config['new_image'] = $_SERVER['DOCUMENT_ROOT'].'/images/uploads/'.$imageName; 
    $this->load->library('image_lib', $config); 
    if (! $this->image_lib->resize()){echo $this->image_lib->display_errors();} 


    $this->image_lib->clear(); 






    $this->load->view('admin/upload_form',array('error' => ' ')); 





} 

請解決我的問題我是在工作,因爲使用GD庫調整未安裝/在機器上配置不正確,圖像上週和問題得到不解決

+0

我使用JPG,JPEG,PNG文件,如果我添加GD庫即使再發行不解決,請幫助。 –

+0

我對GD lib根本不熟悉,但我有兩個想法。在第二部分中,您有'$ config ['create_thumb'] = FALSE;'如果將它設置爲'TRUE',會發生什麼?如果你只是評論第一部分並且只運行第二部分會發生什麼? – danneth

回答

0

你。安裝GD可能會解決這個問題。

GD php.net Page

+0

如果GD庫存在問題,那麼爲什麼要創建一個縮略圖?沒有問題eith GD庫 –

+0

不需要任何其他庫需要:-( 問題可以解決,如果我們只加載圖像庫一次,在函數的開始。 和只有初始化配置的第二個拇指。成功的代碼是作爲下輸送:-{} –