사용자가 내 웹 사이트에 제품을 추가 할 수 있도록 CodeIgniter에 대한 웹 사이트를 만들고 있습니다. 그림이 축소판을 만들 수 있도록 크기 조정 기능을 만들었습니다. 이제이 축소판 그림의 너비가 168px 및 높이 : 112px보다 큰 경우에만 크기가 조정됩니다. 사진이 그보다 작 으면 사진의 크기가 조절되지 않습니다. 업로드 한 모든 사진의 가로 및 세로 크기는 각각 168px 및 112px 인 미리보기 이미지를 원합니다.Codeigniter 그림 크기 조정이 제대로 작동하지 않습니다.
썸네일 이미지 코드 :
$dataThumb = $this->upload->data();
$configThumb['image_library'] = 'gd2';
$configThumb['source_image'] = './upload/'.$dataThumb["raw_name"].$dataThumb['file_ext'];
$configThumb['new_image'] = './upload/'.'thumb_'.$dataThumb["raw_name"].$dataThumb['file_ext'];
$configThumb['create_thumb'] = TRUE;
$configThumb['maintain_ratio'] = TRUE;
$configThumb['width'] = 168;
$configThumb['height'] = 112;
내 전체 업로드 제품 코드 :
public function upload() {
$this->load->library('upload');
$this->load->library('image_lib');
$config['upload_path'] = './upload/';
$config['allowed_types'] = 'gif|jpg|png|bmp|jpeg';
$config['max_size'] = '0';
$config['max_width'] = '0';
$config['max_height'] = '0';
$config['encrypt_name']= true;
$this->upload->initialize($config);
if(!$this->upload->do_upload('userfile')){
$error = array('error'=>$this->upload->display_errors());
$this->load->view('product_form', $error);
}else{
//Main image
$data = $this->upload->data();
$config['image_library'] = 'gd2';
$config['source_image'] = './upload/'.$data["raw_name"].$data['file_ext'];
$config['new_image'] = './upload/'.'new_'.$data["raw_name"].$data['file_ext'];
$config['create_thumb'] = FALSE;
$config['maintain_ratio'] = FALSE;
$config['width'] = 547;
$config['height'] = 430;
//Thumb image
$dataThumb = $this->upload->data();
$configThumb['image_library'] = 'gd2';
$configThumb['source_image'] = './upload/'.$dataThumb["raw_name"].$dataThumb['file_ext'];
$configThumb['new_image'] = './upload/'.'thumb_'.$dataThumb["raw_name"].$dataThumb['file_ext'];
$configThumb['create_thumb'] = TRUE;
$configThumb['maintain_ratio'] = TRUE;
$configThumb['width'] = 168;
$configThumb['height'] = 112;
$this->image_lib->initialize($config);
$this->image_lib->resize();
$this->image_lib->initialize($configThumb);
$this->image_lib->resize();
$this-> db-> insert('products', array(
'user_id' => $_SESSION['user_id'],
'product_foto' => 'new_'.$data["raw_name"].$data['file_ext'],
'product_foto_thumb' => 'thumb_'.$dataThumb["raw_name"].$dataThumb['file_ext'],
'product_naam' => $this->input->post('product_naam'),
'product_beschrijving' => $this->input->post('product_beschrijving'),
'ophaal_plaats' => $this->input->post('ophaal_plaats'),
'category_id' => !empty($this->input->post('category_id')) ? $this->input->post('category_id') : 0,
'date_created' => date('Y-m-d'),
'date_updated' => date('Y-m-d')
));
$data['img'] = base_url().
'/upload/new_'.$data["raw_name"].$data['file_ext'];
$dataThumb['img'] = base_url().
'/upload/thumb_'.$dataThumb["raw_name"].$dataThumb['file_ext'];
header('location:https://kadokado-ferran10.c9users.io/Product/');
}
}
(당신의 치수보다 큰) 당신은 무엇을 의미합니까했다 : 아래 은 결과입니까? – JohnDoe122
문제는 내가 업로드 한 작은 그림이 168 너비와 112 높이로 크기가 조정되지 않는다는 것입니다. – JohnDoe122
디버깅을 설정했기 때문에'system/libraries/Image_lib.php'를 통해 볼 수 있고 그 마지막 내용 $ width 및 $ height는?로 설정됩니다. (또는 관심있는 지점에'log_message' 명령을 넣으십시오.) – ourmandave