CodeIgniter Forums
upload image thumbs can resize as exactly measure ?? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: upload image thumbs can resize as exactly measure ?? (/showthread.php?tid=49739)



upload image thumbs can resize as exactly measure ?? - El Forum - 03-01-2012

[eluser]ludo31[/eluser]
Hello ;
I don't know if you have a same problem but when I upload an image , the size of thumbs is not exactly the same than in configuration :

here is my code :

Code:
public function do_upload()
             {
                
                  $identifiant_chaussure = $this->input->post('identifiant');
                  
                  
                //  echo ('identifiant '.$identifiant_chaussure) ;  exit ;
                  
                
                $config['upload_path'] = './image/';
                $config['allowed_types'] = 'gif|jpg|png';
                $config['max_size']     = '0';
                $config['max_width']  = '0';
                $config['max_height']  = '0';
                
                $config['encrypt_name'] = true ;
                
                $this->load->library('upload', $config);
        
                if ( ! $this->upload->do_upload())
                {
                        $error = array('error' => $this->upload->display_errors());
                        
                        $this->load->view('image_view', $error);
                }      
                else
                {
                        // $data = array('upload_data' => $this->upload->data());
                        
                        $data = $this->upload->data();
                        
                        
                        
                        // print_r($data);exit ;
                        
                        $this->load->view('upload_success', $data);
                        
                         $source = element('full_path',$data);
                        
                        
                        $config['image_library'] = 'gd2';
                        $config['source_image'] = $source;
                        $config['new_image'] = './image/thumbs/';
                        $config['create_thumb'] = TRUE;
                        $config['thumb_marker']='';
                        $config['maintain_ratio'] = TRUE;
                        $config['width'] = 350;
                        $config['height'] = 225;

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

                        $this->image_lib->resize();
                        
                        
                        
                        $nom_path = element('file_name',$data);
                        
                       // echo $nom_path ;
                      //  echo ('identifiant '.$identifiant_chaussure) ;  exit ;
                      
                      
                      $this->site_model->ajoutImages($nom_path , $identifiant_chaussure);
      
      
                      
                     // redirect('site');
      
      
        $data['identifiant']=  $identifiant_chaussure ;
                      
                    
                      
      $this->load->view('image_view',$data);
                        
                        
                            
                        
                        
                        
  }
                
                
                
             }

in the thumbs configuration we precise :

Code:
$config['width'] = 350;
                        $config['height'] = 225;

but when I check the folder where thumbs has stored they are : 156 x 225

I thought that the thumb must resize as thos value


upload image thumbs can resize as exactly measure ?? - El Forum - 03-01-2012

[eluser]Matalina[/eluser]
Code:
$config['maintain_ratio'] = TRUE;

You are maintaining ratio. If the image is taller than it is wide, it is going to use the one that is maxed out and just resize.

If you don't maintain ration you need to set the dimension that should be maxed out regardless.