2010-03-09 6 views
0

Fonction:problème Modifier la taille() de 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(); 

} 

et donne une page blanche, ne pas les erreurs d'affichage. Mais si j'efface ces lignes, ça marche bien!

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

Répondre

0

La bibliothèque gd2 est-elle installée sur votre système?

Y a-t-il quelque chose dans les fichiers journaux?

+0

Le problème était que l'image utilisée était avec l'extension .JPG en majuscule. – Mango

0
problème

est parce que vous n'avez pas create_thumb = TRUE

essayer former un tableau de cette façon. c'est propre et sans erreur.

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(); 
    }