使用Laravel Image Intervention,如何从URL获取图像并调整大小

时间:2019-02-05 23:06:44

标签: laravel intervention

我正在尝试从网址中提取图片,调整图片大小并将其存储在S3存储桶中。如果我上传图片,但从网址中提取图片却无法正常工作,则代码工作正常。这就是我如果我将第一行替换为上传请求,那么它将起作用。

$photo = file_get_contents('domain.com/img.jog');
$photo_link = time().'-'.$photo->getClientOriginalName();
$imageName = 'photos/'.$photo_link;

$extension = $photo->getClientOriginalExtension();

$image_resize = \Image::make($photo)->resize(2000, null, function ($constraint) {
    $constraint->aspectRatio();
})->encode($extension);


$t = \Storage::disk('s3')->put($imageName, (string)$image_resize, 'public');

这使我收到错误消息,要求在字符串上调用成员函数getClientOriginalName()

我如何从URL中提取图像,调整其大小并将其存储在Amazon存储桶中?

0 个答案:

没有答案