我正在开发一个codeigniter项目,用户可以在其中创建个人资料并上传他们的图片。我想创建一个图像缩略图(200 X 200)并将其保存在目录中。我的代码在上传图像时工作得很好,并且还将图像名称存储在数据库中,但问题是它没有调整图像大小。我想调整所有图像的大小(200 X 200),然后将它们存储在目录中。
这是控制器
public function FunctionName()
{
$fname = ucwords($this->input->post('fname'));
$lname = ucwords($this->input->post('lname'));
$prof_pic = $_FILES['profile_pic']['name'];
$config = array ('upload_path' => './images/students/',
'allowed_types' => "jpeg|jpg|png",
'overwrite' => TRUE,
'file_name' => $Maxtype."_".$fname."_".$lname,
'remove_spaces' => TRUE,
'image_library' => gd2,
'source_image' => $prof_pic,
'new_image' => './images/students/',
'maintain_ratio' => TRUE,
'height' => 200,
'width' => 200
);
$this->load->library('upload', $config);
$this->upload->do_upload('profile_pic');
$extension = pathinfo($prof_pic);
$ext = $extension['extension'];
$image = $config['file_name'].".".$ext;
$data = array('std_fname' => $fname,
'std_lname' => $lname,
'profile_pic' => $image
);
}