[eluser]mikegeorgeff[/eluser]
Is there a way to resize an image twice. I have a form where I'm uploading an image and I need a large view and a smaller image. I currently have the smaller image size working but I can't figure out how to resize the source image.
Here is the code I have:
Code:
function addProduct()
{
$now = date("Y-m-d H:i:s");
$data = array(
'name' => $this->input->post('name'),
'desc' => $this->input->post('desc'),
'category_id' => $this->input->post('category_id'),
'featured' => $this->input->post('featured'),
'price' => $this->input->post('price'),
'shipping' => $this->input->post('shipping'),
'date' => $now
);
if($_FILES)
{
$config['upload_path'] = './uploads/';
$config['allowed_types'] = 'gif|jpg|jpeg|png';
$config['max_size'] = '2048';
$config['remove_spaces'] = TRUE;
$config['overwrite'] = FALSE;
$this->load->library('upload', $config);
if(!$this->upload->do_upload('image'))
{
$this->upload->display_errors();
exit();
}
$image_data = $this->upload->data();
if($image_data['file_name'])
{
$data['image'] = $image_data['file_name'];
}
$config['source_image'] = $image_data['full_path'];
$config['new_image'] = './uploads/thumbs/';
$config['maintain_ratio'] = TRUE;
$config['height'] = 143;
$config['width'] = 100;
$this->load->library('image_lib', $config);
if(!$this->image_lib->resize())
{
$this->image_lib->display_errors();
exit();
}
if($image_data['file_name'])
{
$data['thumbnail'] = 'thumbs/'.$image_data['file_name'];
}
}
$this->db->insert('product', $data);
}