[eluser]CodyPChristian[/eluser]
Hey guys, been awhile since I've been around here.
I have a function that uploads a file, then it runs two image_lib processes on it.
1. Uploads image
2. Creates thumb of image
3. Crops thumb image
4. Submits data to database
The code I've pasted below I've removed a lot of the code and only left the two processing functions because everything else is working, however the cropping is not working and it doesn't error it just doesn't crop and keeps going.
I want to note once this is working a lot of this will be moved to model functions.
Code:
//previous code nulled out of this paste
//Gets Upload data from upload function.
$upload_data = $this->upload->data();
$filename = $upload_data['file_name'];
//Process filename for thumbnail from original filename.
$filename_thumb = $this->cadmin->ProcessFileName($filename);
//Config for image_lib resizing of thumbnail.
$config1['image_library'] = 'gd2';
$config1['source_image'] = ''.$path_final.$filename.'';
$config1['create_thumb'] = TRUE;
$config1['maintain_ratio'] = TRUE;
$config1['width'] = 100;
$config1['height'] = 100;
$config1['master_dim'] = 'height';
$this->load->library('image_lib', $config1);
$this->image_lib->initialize($config1);
$this->image_lib->resize();
//if fails take to page and display errors
if(!$this->image_lib->resize()){
$data['error'] = '<div class="error_msg">'.$this->image_lib->display_errors().'</div>';
$this->load->view('admin/pages/library_add', $data);
} else {
//if success clear previous image_lib config and keep going
$this->image_lib->clear();
$config2['image_library'] = 'gd2';
$config2['source_image'] = ''.$path_final.$filename_thumb.'';
$config2['x_axis'] = '100';
$config2['y_axis'] = '100';
//crops image based on config above
$this->load->library('image_lib', $config2);
$this->image_lib->initialize($config2);
$this->image_lib->crop();
//if fails take to page and display errors
if(!$this->image_lib->crop()){
$data['error'] = '<div class="error_msg">'.$this->image_lib->display_errors().'</div>';
$this->load->view('admin/pages/library_add', $data);
} else {
//if success submit to db and redirect to appropriate place
//Submits to DB - code nulled out of this paste
}
}
Thanks!