0
如何使用PHP降低圖像的質量?在php中降低圖像質量
upload_mode = @$this->setting->upload_mode?:'file';
$upload_path = @$this->setting->upload_path?:'uploads/';
$file = Request::file($name);
$fm = array();
$fm['name'] = $_FILES[$name]['name'];
$fm['ext'] = $file->getClientOriginalExtension();
$fm['size'] = $_FILES[$name]['size'];
$fm['content_type'] = $_FILES[$name]['type'];
if($upload_mode=='database') {
$fm['filedata'] = file_get_contents($_FILES[$name]['tmp_name']);
DB::table('cms_filemanager')->insert($fm);
$id_fm = DB::getPdo()->lastInsertId();
DB::table('cms_filemanager')->where('id',$id_fm)->update(['id_md5' =>md5($id_fm)]);
$filename = 'upload_virtual/files/'.md5($id_fm).'.'.$fm['ext'];
}else{
if(!file_exists($upload_path.date('Y-m'))) {
if(!mkdir($upload_path.date('Y-m'),0777)) {
die('Gagal buat folder '.$upload_path.date('Y-m'));
}
}
$filename = md5(str_random(12)).'.'.$fm['ext'];
$file->move($upload_path.date('Y-m'),$filename);
$filename = $upload_path.date('Y-m').'/'.$filename;
}
$url = asset($filename);
已經有人幫我嗎?我需要添加什麼才能使它像我需要的那樣工作?
你想調整它,或者只是降低質量?否則'imagejpeg()'將是一個很好的解決方案:http://php.net/manual/en/function.imagejpeg.php – Thoby