[eluser]old_guy[/eluser]
I'm having a problem getting the resize function to work. In the code below, I upload the image into folder images/clients (working OK). I want then resize this image to a more suitable size and overwrite the original image (not working). Next, I want to again resize the image to thumbnail and save to folder images/thumb (again, not working). I also write the image path for both to my db, which is not a problem.
I'm at a loss as to why the resize is not working. Maybe a fresh set of eyes on my code can help me see the error of my way.
Thanks in advance.
class Gallery_model extends Model {
var $gallery_path;
var $gallery_path_url;
function Gallery_model() {
parent::Model();
$this->gallery_path = realpath(APPPATH . '../images/client');
$this->gallery_path_url = base_url().'images/client';
}
function do_upload() {
$config = array(
'allowed_types' => 'jpg|jpeg|gif|png',
'upload_path' => $this->gallery_path,
'overwrite' => true,
);
$this->load->library('upload', $config);
$this->upload->do_upload();
$image_data = $this->upload->data();
// resize uploaded image
$config = array(
'source_image' => $image_data['full_path'],
'new_image' => $this->gallery_path,
'maintain_ration' => true,
'width' => 250,
'height' => 250,
);
$this->load->library('image_lib', $config);
$this->image_lib->resize();
$this->image_lib->clear();
// write image path to db
$img_path = array('image' => 'images/client/' .$image_data['file_name']);
$this->db->where('id', $this->uri->segment(4));
$this->db->update('cdata',$img_path);
// create image thumbnail
$config = array(
'source_image' => $image_data['full_path'],
'new_image' => $this->gallery_path . '/thumb',
'creat_thumb' => true,
'maintain_ration' => true,
'width' => 100,
'height'=> 100,
);
$this->load->library('image_lib', $config);
$this->image_lib->resize();
// write thumbnail to db
$thumb_path = array('image_thumb' => 'images/thumb/' $image_data['file_name']);
$this->db->where('id', $this->uri->segment(4));
$this->db->update('cdata', $thumb_path);
}
}