[eluser]Pokhara[/eluser]
image are not so clear with this code and also sometimes it resize image and sometimes not, pls help
Code:
function do_upload() {
$config = array(
'allowed_types' => 'jpg|jpeg|gif|png',
'upload_path' => $this->gallery_path,
'max_size' => 9000
);
$this->load->library('upload', $config);
$this->upload->do_upload();
$image_data = $this->upload->data();
$this->load->library('image_lib', $config);
$this->image_lib->resize();
$this->load->library('image_lib');
/*echo '<pre>';
print_r($image_data);*/
//[ THUMB IMAGE ]
$img_config_0['image_library'] = 'GD';
$img_config_0['source_image'] = $image_data['full_path'];
//$img_config_0['new_image'] = $this->gallery_path . '/thumbs';
$img_config_0['maintain_ratio'] = TRUE;
$img_config_0['width'] = 200;
$img_config_0['height'] = 125;
$img_config_0['create_thumb'] = true;
//[ MAIN IMAGE ]
$img_config_1['image_library'] = 'GD';
$img_config_1['source_image'] = $image_data['full_path'];
$img_config_1['maintain_ratio'] = TRUE;
$img_config_1['width'] = 620;
$img_config_1['height'] = 900;
$img_config_1['create_thumb'] = FALSE;
for($i=0;$i<2;$i++){
eval("\$this->image_lib->initialize(\$img_config_".$i.");");
if($this->image_lib->resize()){
echo "Success";
}else{
echo "Failed." .$i . $this->image_lib->display_errors();
}
}
//insert to database
$image_data_and_post_data = array(
'categories_id' => $_POST['categories_id'] ,
'description' => $_POST['description'],
'title' => $_POST['title'],
'active' => $_POST['active'],
'featured' => $_POST['featured'],
'date' => $_POST['date'],
//'thumb_name' => $image_data['file_name'],
'photo' => $image_data['file_name'],
'raw' => $image_data['raw_name'],
'ext' =>$image_data['file_ext']
);
$this->db->insert('gal_photos',$image_data_and_post_data);
redirect('admin1/gallery');
}