【问题标题】:Laravel Intervention Image not workingLaravel 干预图像不起作用
【发布时间】:2015-03-12 03:24:44
【问题描述】:

我安装了 Laravel Intervention Image 类的作曲家,来自 this 教程,当我输入作曲家更新时,作曲家返回:

D:\WEB\htdocs\zanbil>composer update
Loading composer repositories with package information
Updating dependencies (including require-dev)
  - Installing intervention/image (dev-master b91b0d6)
    Downloading: 100%
    Downloading: 100%

intervention/image suggests installing intervention/imagecache (Caching extension for the Intervention Image library)
intervention/image suggests installing ext-imagick (to use Imagick based image processing.)
Writing lock file
Generating autoload files
Generating optimized class loader

这就是我将要使用的干预图像

$image=Input::file('image');
        $name = Input::file('image')->getClientOriginalName();
        var_dump(Image::make($image->getRealPath()->resize('280','280')->save('public/up/city/'.$name)));

当我运行该代码时,Laravel 返回(使用浏览器):

Symfony\Component\Debug\Exception\FatalErrorException (E_ERROR) 在非对象上调用成员函数 resize()

有什么问题?

【问题讨论】:

  • 您根据getRealPath() 的结果调用resize。我想你想做这样的事情:Image::make($image->getRealPath())->resize('280', '280')->save('public/up/city/'.$name)
  • @lukasgeiter 谢谢,这就是答案
  • 不客气。我投票决定关闭,因为这只是一个错字,而且将来不太可能对其他人有所帮助。
  • @lukasgeiter 不知何故,您的解决方案对我不起作用:图像源不可读
  • @Volatil3 那么你的问题可能与这篇文章无关。请提出一个新问题。

标签: php laravel


【解决方案1】:

您对 getRealPath() 的结果调用 resize。我想你想做这样的事情:

Image::make($image->getRealPath())->resize('280', '280')->save('public/up/city/'.$name)

感谢lukasgeiter的回答

【讨论】:

    猜你喜欢
    • 2019-06-19
    • 2015-09-09
    • 2015-02-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-07-04
    • 2019-01-16
    • 2017-01-28
    相关资源
    最近更新 更多