使用 laravel 中的 Intervention 库制作图像模糊效果

make image blur effect with Intervention library in laravel

我正在尝试为我的图像添加模糊效果。我正在使用 laravel 5.2 和 Intervention Image 2 library. here's blur method 。我在我的代码中做了完全相同的事情,但它什么也没做(图像保持不变)。这是代码: 在我存储输入数据和图像的控制器中,我调用了 makeBlur() 辅助函数。图片路径存储在 $path_preview

控制器:

// some code ...
makeBlur($path_preview); // <-- looks like /uplodas/image.jpg
// some code ....
$model->path_preview = $path_preview;
$model->save();

这里是辅助函数:

// $image is string (stores the path of file)
function makeBlur($image){
  $path = public_path() . $image; // get image path add public/ in front of it
  $blurredImg = \Image::make($path);
  $blurredImg->blur(45);
}

没有错误,只是没有任何反应。也许我不知道它是如何工作的

应用模糊后保存图像

$blurredImg->blur(45)->save($image);