CodeIgniter Forums
Help multiple resize - 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: Help multiple resize (/showthread.php?tid=48494)



Help multiple resize - El Forum - 01-18-2012

[eluser]amina[/eluser]
Hi, I have a function multiple resize. My problem is that upload the first and the second resize.
My class:
Code:
class Uploads {

private $CI;
private $name;

function __construct($param = array()){
  $this->CI =& get_instance();
  $this->name = $param['name'];
              
              
                
}


function do_upload_image() {
            
           if (!empty($_FILES['userfile']['name'])){
                            $config['upload_path']  = IMAGE_UPLOAD_PATH;
                            $config['allowed_types'] = 'gif|jpg|png';
                            $config['file_name']  = $this->name;
                            $config['max_size']   = '5000';
                            $config['max_width']  = '2024';
                            $config['max_height']  = '1768';

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

                            if (!$this->CI->upload->do_upload('userfile'))
                                    return array('error' => $this->CI->upload->display_errors());
                            else  
                                    return array('upload_data' => $this->CI->upload->data());
                                    
                                    $imgpath = $this->CI->upload->upload_path.$this->CI->upload->file_name;

                                    $config = array(
                                            'image_library'  => 'GD2',
                                            'source_image'  => $imgpath,
                                            'create_thumb'  => TRUE,
                                            'maintain_ratio' =>FALSE,
                                            'height'   => 80,
                                            'width'    => 100
                                    );
                                    $this->CI->load->library('image_lib',$config);
                                    if (!$this->CI->image_lib->resize())
                                            return array('error' => $this->image_lib->display_errors());
                                      else
                                            return array('upload_data' => $this->CI->upload->data());
                                  

                                            $config = array(
                                            
                                            'create_thumb' => FALSE,
                                            'maintain_ratio'=> FALSE,
                                            'width'   => 425,
                                            'height'  => 318
                                    );

                                    $this->CI->image_lib->initialize($config);
                                    if (!$this->CI->image_lib->resize())
                                            return array('error' => $this->image_lib->display_errors());
                                    else
                                            return array('upload_data' => $this->CI->upload->data());
                                            
                                            
                                            $config = array(
                                            
                                            'create_thumb' => FALSE,
                                            'maintain_ratio'=> FALSE,
                                            'width'   => 130,
                                            'height'  => 170
                                    );

                                    $this->CI->image_lib->initialize($config);
                                    if (!$this->CI->image_lib->resize())
                                            return array('error' => $this->image_lib->display_errors());
                                    else
                                            return array('upload_data' => $this->CI->upload->data());
                                            
                                      
                                        
                                            $config = array(
                                            
                                            'create_thumb' => FALSE,
                                            'maintain_ratio'=> FALSE,
                                            'width'   =>70 ,
                                            'height'  => 55
                                    );

                                    $this->CI->image_lib->initialize($config);
                                    if (!$this->CI->image_lib->resize())
                                            return array('error' => $this->image_lib->display_errors());
                                    else
                                            return array('upload_data' => $this->CI->upload->data());
                                            
                                        
                                  
                              
                              
                          
                                    
                 }
                          
        }
Thanks!


Help multiple resize - El Forum - 01-25-2012

[eluser]jjDeveloper[/eluser]
Looks to me like you are returning control to whichever class implements this class before its executing the whole script.


Help multiple resize - El Forum - 01-25-2012

[eluser]amina[/eluser]
Thank you for your response