Vin*_*eet 7 php laravel-5 intervention laravel-5.1
我正在使用intervention/image 2.3. 当我尝试上传图像时,出现以下错误:
AbstractEncoder.php 第 212 行中的 InvalidArgumentException
质量必须在 0 到 100 之间
下面是我的代码:
$file = Input::file('image');
$filename = time() . '.' . $file->getClientOriginalExtension();
Image::make($file)->resize(50, 50)->save(storage_path() . DIRECTORY_SEPARATOR . 'uploads', $filename);
Run Code Online (Sandbox Code Playgroud)
任何单一的指导都会对我有很大帮助。根据这个URL,我尝试传递第二个可选参数,即质量,但没有奏效。我什至试过
Image::make($file)->resize(50, 50)->save(storage_path() . DIRECTORY_SEPARATOR . 'uploads'. $filename, 50);
Run Code Online (Sandbox Code Playgroud)
小智 2
我遇到过这个问题,我通过以下代码解决了它:
$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);
Run Code Online (Sandbox Code Playgroud)
检查http://image.intervention.io/api/save了解更多...