Welcome Guest, Not a member yet? Register   Sign In
Resize image after upload.
#3

[eluser]Dan Tdr[/eluser]
Code:
function do_upload()
    {
        //UPLOAD
        $config['upload_path'] = './uploads/';
        $config['allowed_types'] = 'gif|jpg|png';
        $config['max_size']    = '2000';
        $config['max_width']  = '1280';
        $config['max_height']  = '1024';
        
        $this->load->library('upload', $config);
        $this->upload->do_upload();
        
        $data = array('upload_data' => $this->upload->data());
        $file_data = $this->upload->data();
        
        $file_raw = $file_data['raw_name'];
        $file_name = $file_data['orig_name'];
        $file_ext = $file_data['file_ext'];
        $file_size = $file_data['file_size'];
        $file_width = $file_data['image_width'];
        $file_height = $file_data['image_height'];
        
        // THUMB
                $config[] = 'GD2';
                $config['source_image'] = './uploads/'.$file_name;
           $config['new_image'] = './thumb_'.$file_name; //path : './the place were you want the thumb to be saved/file begining'.filename;
           $config['maintain_ratio'] = TRUE; // keep the ratio aspect on
           $config['height'] = 150; // max height(if maintain_ratio is TRUE if it`s set on false it will just make the height the size you want it no matter what the picture ratio is)
          $config['width'] = 150; // max width (if maintain_ratio is TRUE if it`s set on false it will just make the height the size you want it no matter what the picture ratio is)
                $config['quality'] = 100; // quality
        
                $this->load->library('image_lib', $config);
                $this->image_lib->resize();
                
        $this->_container = $this->config->item('FAL_template_dir').'template/container';
        $this->_upload_success = $this->config->item('FAL_template_dir').'template/upload_success';
        $id = $this->uri->segment(3);
        $data['heading'] = 'VIEW users';
        $data['controller'] = 'myaccount';
        $data['page'] = $this->config->item('FAL_template_dir').'template/upload_success';
                        
        $this->load->vars($data);
        
        $this->load->view($this->_container, $data);  
    }
this is what i use.. after the //thumb you can put any width/height and it will fit into thouse


Messages In This Thread
Resize image after upload. - by El Forum - 10-02-2008, 09:05 AM
Resize image after upload. - by El Forum - 10-02-2008, 09:25 AM
Resize image after upload. - by El Forum - 10-08-2008, 03:17 PM



Theme © iAndrew 2016 - Forum software by © MyBB