0
我想在我的網站上傳大圖像。我想減小使用codeigniter的人的大小。所以我在做這個代碼Codeigniter圖像壓縮不起作用
function upload_image($data) {
$config['upload_path'] = './temp/';
$config['allowed_types'] = 'gif|jpg|png';
$config['max_size'] = 10000;
$this->load->library('upload', $config);
if (!$this->upload->do_upload('image')) {
$error = array('error' => $this->upload->display_errors());
pre($error);
} else {
$config = array();
$data = array('upload_data' => $this->upload->data());
$config['image_library'] = 'gd';
$config['source_image'] = './temp/' . $data['upload_data']['file_name'];
$config['create_thumb'] = FALSE;
$config['maintain_ratio'] = TRUE;
$config['quality'] = 50;
$config['new_image'] = './temp/' . $data['upload_data']['file_name'];
$this->load->library('image_lib', $config);
$this->image_lib->resize();
pre($data);
}
}
但是圖像沒有被壓縮。原始和上傳的大小是相同的。我錯在哪裏?
使用此參數與質量PARAM那麼它會降低圖像 $配置[大小」寬度'] = 75; $ config ['height'] = 50; –