Welcome Guest, Not a member yet? Register   Sign In
custom image width and height problem
#1

[eluser]rashgang[/eluser]
Hi All,

I am using image library to resize an image to 3 resize options. but after using the image library of codeigniter it is resizing to a particular widht and height. i am not getting the mentioned size width and height. Please check with the below code
Code:
$data = array('upload_data' => $this->upload->data());
         //print_r($_FILES);
        
    $this->load->library('image_lib');
    $configSize['image_library']   = 'gd2';
     $configSize['source_image']    = $data['upload_data']['full_path'];
      //$configSize['create_thumb']    = TRUE;      
     //$configSize['maintain_ratio']  = TRUE;
     // $configSize['master_dim']  = 'auto';
    

    
    
  
     $configSize['width']           = 960;  
      $configSize['height']           = 240;
      
      //$sourceRatio = $sourceWidth / $sourceHeight;
    
      $configSize['new_image']   = APPPATH.'slider_image/resized_image/960x240'. $data['upload_data']['file_name'];
     // $configSize['x_axis'] = '200';
//$configSize['y_axis'] = '100';
     // $configSize['quality']    = 100;
    
    // $sourceRatio = $orig_width / $orig_height;
    //$targetRatio = $configSize['width'] / $configSize['height'];
    
    
     $this->image_lib->initialize($configSize);
    
     $this->image_lib->resize();
    
    
    
    
    
      /* Second size */    
     $configSize2['image_library']   = 'gd2';
     $configSize2['source_image']    = $data['upload_data']['full_path'];
     $configSize2['create_thumb']    = FALSE;
     $configSize2['maintain_ratio']  = TRUE;
     $configSize2['width']           = 800;
     $configSize2['height']          = 200;
     $configSize2['new_image']   = APPPATH.'slider_image/resized_image/800x200'. $data['upload_data']['file_name'];
    
     $this->image_lib->initialize($configSize2);
     $this->image_lib->resize();
      //$this->image_lib->clear();
    
    
          /* Third size */    
     $configSize3['image_library']   = 'gd2';
     $configSize3['source_image']    = $data['upload_data']['full_path'];
     $configSize3['create_thumb']    = FALSE;
     $configSize3['maintain_ratio']  = TRUE;
     $configSize3['width']           = 480;
     $configSize3['height']          = 120;
     $configSize3['new_image']   = APPPATH.'slider_image/resized_image/480x120'. $data['upload_data']['file_name'];
    
     $this->image_lib->initialize($configSize3);
     $this->image_lib->resize();


it is resizing to 160 * 120, 267 * 200, 320 * 240(960*240)

960 * 240 resizing to 320 * 240 option

Please help me how to resize to these sizes .




Theme © iAndrew 2016 - Forum software by © MyBB