Welcome Guest, Not a member yet? Register   Sign In
Resize and Crop X and Y
#1

[eluser]Thiago Leao[/eluser]
Hi friend, I have a problem.
I want to resize the image to 120x90.

When someone sends horizontal photo is right, but when you send a picture usually cuts the vertical head.

How do I cut it from the top position?

thanks

Code:
if (!empty($_FILES['userfile_'.$i])){
                            
                    $config['upload_path'] = $diretorio;
                    $config['allowed_types'] = 'gif|jpg|jpeg|png';
                    $config['remove_spaces'] = TRUE;
                    $config['encrypt_name'] = TRUE;
                    $config['max_size'] = '8192'; // 8Mbs
                    
                    $this->load->library('upload', $config);
                    $this->upload->initialize($config);
                    
                    $this->upload->do_upload('userfile_'.$i);    
                    $image_data = $this->upload->data();
                    
                    $configLarge = array(
                        'source_image' => $diretorio.$image_data['file_name'],
                        'new_image' => $diretorio,
                        'master_dim' => 'auto',
                        'maintain_ratio' => true,
                        'width' => 800,
                        'height' => 600
                    );          
                
                    $this->load->library('image_lib');
                    $this->image_lib->initialize($configLarge);
                    $this->image_lib->resize();            
                    $this->image_lib->clear();
                    
                    
                    $configThumb = array(
                        'source_image' => $image_data['full_path'],
                        'new_image' => $diretorio.substr($image_data['file_name'], 0, -4).'_thumb.'.end(explode(".", $image_data['file_name'])),
                        'maintain_ratio' => false,
                        'master_dim' => 'auto',
                        'width' => 120,
                        'height' => 90
                    );    

                    $this->image_lib->initialize($configThumb);
                    $this->image_lib->resize_and_crop();
                    
                    
                    $data['id_products']     = $this->input->post('id_products');
                    $data['descricao']       = $this->input->post('descricao');
                    $data['thumb']           = $configThumb['new_image'];
                    $data['imagem']          = $configLarge['source_image'];
                    
                    $this->load->model('administracao/cad_produto_model');
                    $this->cad_produto_model->cadastrar_img($data);
                }
                    
            }
            redirect(base_url().'administracao/cad_produto/upload/'.$data['id_products'], 'refresh');




Theme © iAndrew 2016 - Forum software by © MyBB