【发布时间】:2015-04-14 14:47:19
【问题描述】:
我正在尝试将我的文件上传为圈子,但无法正常工作。 我已经看到一些关于对图像应用掩码的主题,但是当我应用掩码时,它需要很长时间并且服务器会关闭请求。
我正在为 Laravel 使用 Intervention Image 库
我的代码如下:
$identifier = "{$this->loggedUser->id}" . str_random(9) . ".{$file->getClientOriginalExtension()}";
$mask = $this->createCircleMask(200, 200);
$thumbMask = $this->createCircleMask(40, 40);
Image::make($file->getRealPath())->mask($mask)->save(public_path("images/profile/{$identifier}"));
Image::make($file->getRealPath())->mask($thumbMask)->save(public_path("images/profile/thumbs/{$identifier}"));
createCircleMask 方法如下所示:
public function createCircleMask($width, $height)
{
$circle = Image::canvas($width, $height, '#000000');
return $circle->circle($width - 1, $width / 2, $height / 2);
}
【问题讨论】:
标签: php image laravel laravel-5 intervention