Как изменить размер изображения с помощью Codeigniter

Я пытаюсь загрузить изображение и изменить размер изображения. Мне нужно как исходное изображение, так и изображение большого пальца.

Но проблема заключается в том, что код изменения размера изображения не работает.

Кодирование загрузки изображений прекрасно работает в хранилище изображения в папке, но код изменения размера изображения не работает.

Как я могу это сделать ?

Вот мой код

public function add_images(){ $this->form_validation->set_rules('description','Description','required'); $this->form_validation->set_rules('status','Status','required'); if($this->form_validation->run() == TRUE) { // print_r($this->input->post()); $config['upload_path'] = 'public/img/inner_images/'; $config['allowed_types'] = 'gif|jpg|jpeg|png'; // upload only valid images // update library setting of upload $this->load->library('upload', $config); //upload image $this->upload->do_upload('image'); $fInfo = $this->upload->data(); // get all info of uploaded file //for image resize $img_array = array(); $img_array['image_library'] = 'gd2'; $img_array['maintain_ratio'] = TRUE; $img_array['create_thumb'] = TRUE; //you need this setting to tell the image lib which image to process $img_array['source_image'] = $fInfo['full_path']; $img_array['width'] = 113; $img_array['height'] = 75; $this->load->library('image_lib', $img_array); if (!$this->image_lib->resize()) { echo $this->image_lib->display_errors(); exit; } if($fInfo['file_ext'] ==='.gif'||$fInfo['file_ext'] ==='.jpg'|| $fInfo['file_ext'] ==='.jpeg' || $fInfo['file_ext'] ==='.png'|| $fInfo['file_ext'] ===''){ $insert = array( 'inner_image' =>$fInfo['file_name'], 'description' => $this->input->post('description'), 'status' => $this->input->post('status') ); $check = $this->mdl_inner->add_image($insert); if($check){ $this->session->set_flashdata('success',"Image Added Sucessfully"); redirect('admin/inner_gallery/add_images/', 'refresh'); } }else{ $this->session->set_flashdata('error',"Upload Proper Image Format"); redirect('admin/inner_gallery/add_images/', 'refresh'); } } $arrData['middle'] = 'admin/inner/add_image'; $this->load->view('admin/template',$arrData); } 

спасибо, ребята, но я решу эту проблему. через загрузку библиотеки в конструкторе

  $this->load->library('image_lib'); 

после этого добавлен двухстрочный код

  $this->image_lib->clear(); $this->image_lib->initialize($img_array); 

и удалите эту строку

  $this->load->library('image_lib', $img_array); 

мой последний код

 public function add_images(){ $this->form_validation->set_rules('description','Description','required'); $this->form_validation->set_rules('status','Status','required'); if($this->form_validation->run() == TRUE) { // print_r($this->input->post()); $config['upload_path'] = 'public/img/inner_images/'; $config['allowed_types'] = 'gif|jpg|jpeg|png'; // upload only valid images // update library setting of upload $this->load->library('upload', $config); //upload image $this->upload->do_upload('image'); $fInfo = $this->upload->data(); // get all info of uploaded file //for image resize $img_array = array(); $img_array['image_library'] = 'gd2'; $img_array['maintain_ratio'] = TRUE; $img_array['create_thumb'] = TRUE; //you need this setting to tell the image lib which image to process $img_array['source_image'] = $fInfo['full_path']; $img_array['width'] = 113; $img_array['height'] = 75; $this->image_lib->clear(); // added this line $this->image_lib->initialize($img_array); // added this line if (!$this->image_lib->resize()) { echo $this->image_lib->display_errors(); exit; } if($fInfo['file_ext'] ==='.gif'||$fInfo['file_ext'] ==='.jpg'|| $fInfo['file_ext'] ==='.jpeg' || $fInfo['file_ext'] ==='.png'|| $fInfo['file_ext'] ===''){ $insert = array( 'inner_image' =>$fInfo['file_name'], 'description' => $this->input->post('description'), 'status' => $this->input->post('status') ); $check = $this->mdl_inner->add_image($insert); if($check){ $this->session->set_flashdata('success',"Image Added Sucessfully"); redirect('admin/inner_gallery/add_images/', 'refresh'); } }else{ $this->session->set_flashdata('error',"Upload Proper Image Format"); redirect('admin/inner_gallery/add_images/', 'refresh'); } } $arrData['middle'] = 'admin/inner/add_image'; $this->load->view('admin/template',$arrData); }