$config['image_library'] = 'gd2';
$config['quality'] = '99';
$config['source_image'] = $img_path;
$config['create_thumb'] = TRUE;
$config['maintain_ratio'] =TRUE;
$config['width'] = 300;
$config['height'] = 220;
$config['new_image']='uploads/'. $this->upload->data('file');
$this->image_lib->initialize($config);
$this->image_lib->resize();
我在codeignter中使用image_library
,但是它们会产生低质量的图像,有任何方法可以获得图像质量。
这是调整大小后的输出。
答案 0 :(得分:0)
希望这有帮助
function uploadimage()
{
$image_upload_folder='**upload folder path**';
$this->upload_config = array(
'upload_path' => $image_upload_folder,
'allowed_types' => 'png|jpg|jpeg|gif|GIF|PNG|JPEG|Jpeg|JPG',
'remove_space' => TRUE,
'encrypt_name' => TRUE,
);
$this->load->library('upload');
$this->upload->initialize($this->upload_config);
if ( ! $this->upload->do_upload('image')){
return $group_image = '';
}
else{
$data = $this->upload->data();
$this->gallery_path = realpath(APPPATH . '../uploads');//fetching path
$config1 = array(
'source_image' => $data['full_path'], //get original image
'new_image' => $this->gallery_path.'/**thumb image path**', //save as new image //need to create thumbs first
'maintain_ratio' => true,
'width' => 600,
'height' => 600
);
$this->load->library('image_lib', $config1); //load library
$this->image_lib->resize(); //generating thumb
return $group_image = $data['file_name'];
}
}
答案 1 :(得分:0)
尝试一下
$image_data = $this->upload->data();
$configer = array(
'image_library' => 'gd2',
'source_image' => $image_data['full_path'],
'maintain_ratio' => TRUE,
'quality' => '40%'
);
$this->image_lib->clear();
$this->image_lib->initialize($configer);
$this->image_lib->resize();