[eluser]Thiago Leao[/eluser]
Hi guys, I have a question to give a resize my image.
How do I upload an image, and only set the maximum height and width fit?
Example: sending an image with the resolution of 1376 wide x 2448 high.
I want to set the maximum height is 700px, and will automatically adjust itself to the width of this size.
The ideal result stay 393x700
Can anyone help me?
My current code:
Code:
$diretorio = 'assets/uploads/'.$this->session->userdata('username').'/'.$dia.'/';
$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('myfile');
$image_data = $this->upload->data();
$configLarge = array(
'source_image' => $diretorio.$image_data['file_name'],
'new_image' => $diretorio,
'master_dim' => 'auto',
'maintain_ratio' => true,
'height' => 700
);
$this->load->library('image_lib');
$this->image_lib->initialize($configLarge);
$this->image_lib->resize();
$this->image_lib->clear();