Welcome Guest, Not a member yet? Register   Sign In
CodeIgniter multipIe image thumbnailing issue:
#1

[eluser]Unknown[/eluser]
I want to create two thumbnails withh different sizes for same image. In my code only first thumbnail code created
and following error occured.
Error: "Your server does not support the GD function required to process this type of image."

Code:
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' => ' ' ));
        
        
        
        
        
    }
#2

[eluser]Mat-Moo[/eluser]
You need to enable the GD2 module of php, if this is not available, you could try any of these instead imagemagick, netpbm, gd - but it will depend on your php installation (php_info()) may help.
#3

[eluser]Unknown[/eluser]
No Need of any other library required :-( problem can be resolved if we load image library only once, in start of the function. and only initialized config for second thumb. successful code is as under for conveyance:-

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

// this thumbnail created
    $config['image_library'] = 'gd2';
    $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';
    $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);  // this line cause problem
    $this->image_lib->initialize($config); // with this line problem get resolved
    if ( ! $this->image_lib->resize()){echo $this->image_lib->display_errors();}


    $this->image_lib->clear();






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





}




Theme © iAndrew 2016 - Forum software by © MyBB