【问题标题】:Laravel 5.6 Image Intervention Library: 'Image Source Not Readable'Laravel 5.6 图像干预库:“图像源不可读”
【发布时间】:2019-04-22 15:35:08
【问题描述】:

我正在使用图像干预库来调整图像大小,我已完成以下步骤:

1- 安装库:作曲家需要干预/图像

2- 代码中的用法:

    $file            = $request->file('logo');
    $destinationPath = 'db_images/public/';
    $filename        = $file->getClientOriginalName();
    $extension       = explode(".",$filename)[1];
    $name            = md5(microtime()).".".$extension;
    $image_path      = $destinationPath.$name;

$img = Image::make($filename)->resize(254, 179)->保存($image_path);

    $file->move($destinationPath,$img);

问题是: 当我尝试使用上述代码上传文件时,这将返回“图像源不可读”。

请帮助我解决这个问题。谢谢

【问题讨论】:

    标签: laravel image intervention


    【解决方案1】:

    您仅将文件名传递给make 方法,您必须传递文件对象或文件路径:

    文件:

    $img = Image::make($file)->resize(254, 179)->save($image_path);
    

    路径:

    $img = Image::make($file->getRealPath())->resize(254, 179)->save($image_path);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-06-09
      • 2020-04-29
      • 2016-12-19
      • 2016-07-09
      • 1970-01-01
      • 1970-01-01
      • 2019-01-16
      相关资源
      最近更新 更多