我正在使用 intervention/image 2.3
.当我尝试上传图片时,出现以下错误:
InvalidArgumentException in AbstractEncoder.php line 212
Quality must range from 0 to 100
下面是我的代码:
$file = Input::file('image');
$filename = time() . '.' . $file->getClientOriginalExtension();
Image::make($file)->resize(50, 50)->save(storage_path() . DIRECTORY_SEPARATOR . 'uploads', $filename);
任何单一的指导都会对我有很大帮助。根据 this URL 我试图传递第二个可选参数,即质量,但没有奏效。我什至试过
Image::make($file)->resize(50, 50)->save(storage_path() . DIRECTORY_SEPARATOR . 'uploads'. $filename, 50);
最佳答案
我遇到了这个问题,我通过以下代码解决了它:
$file = $request->file('img_profile');
$file_name = date('Ymd-his').'.png';
$destinationPath = 'uploads/images/';
$new_img = Image::make($file->getRealPath())->resize(400, 300);
// save file with medium quality
$new_img->save($destinationPath . $file_name, 80);
查询 http://image.intervention.io/api/save更多...
关于php - 质量必须在 0 到 100 之间 - 干预 Laravel 5.x,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39264205/