[eluser]Bigil Michael[/eluser]
Now iam uploading 5 images at a time. uploading is working perfectly, problem is in image resize. Only my first image is resized other 4 images are in actual size. my code is given below.
Code:
for($i=1;$i<=5;$i++)
{
if($_FILES['photo'.$i]['name']!=''){
//upload thumbnail
$config = array();
$config['file_name'] = 'image'.$i;
$this->load->library('upload');
$this->upload->initialize($config);
if ( ! $this->upload->do_upload('photo'.$i))
{
$data['alert'] = $this->upload->display_errors();
$this->load->view('admin/photos/add', $data); }
else
{
$upload_data = $this->upload->data();
$filename = $upload_data['file_name'];
$width = $upload_data['image_width'];
$height = $upload_data['image_height'];
$config1 = array();
$this->load->library('image_lib');
$config1['source_image'] = absolute_path().'gallery/'.$filename;
//resize image
$sizes = array('width' => $width, 'height' => $height, 'new_width' => 500, 'new_height' => '');
$newsize = array();
$newsize = $this->image_lib->size_calculator($sizes);
$config1['maintain_ratio'] = TRUE;
$config1['width'] = $newsize['new_width'];
$config1['height'] = $newsize['new_height'];
$this->image_lib->initialize($config1);
$this->image_lib->resize();
$this->image_lib->clear();
$this->image_lib->initialize($config1);
$this->image_lib->resize();
$config1['maintain_ratio'] = FALSE;
$config1['width'] = 100;
$config1['height'] = 100;
$config1['create_thumb'] = TRUE;
$config1['thumb_marker'] = 'thumb_';
$this->image_lib->initialize($config1);
$this->image_lib->resize();
$this->Photos_model->save_image('photo'.$i,$filename);
}
}
can anyone help me to solve my problem???
searched in forum got 1 thread ,it says place $this->load->library('image_lib');this code before for loop.
tried but no result.