【问题标题】:Intervention image on HerokuHeroku 上的干预图像
【发布时间】:2018-03-25 14:18:07
【问题描述】:

我正在 Laravel 中开发一个应用程序,该应用程序使用干预图像库和 Imagick 即时上传和调整图像大小。以下是我的代码:

public function saveImage($directory, $imageObject) {
        $imageFile = $imageObject->store('app/'.$directory);

        $filename = str_replace('app/'.$directory.'/','',$imageFile);        
        $imageObject = Storage::get($imageFile);

        $img = Image::make($imageObject);
        $img->resize(null, 40, function ($constraint) {
            $constraint->aspectRatio();
        });
        $imageFile = $img->stream();

        Storage::put('app/'.$directory.'/'.$filename, $imageFile->__toString());

        // $img->save($imagePath);

        return $filename;
    }

但是问题出现在Image::make($imageObject) 行。 Heroku 返回的唯一错误是 503 Service Unavailable。请帮忙。

【问题讨论】:

  • 将您在 config/app 中的日志设置为错误日志,即标准输出,并且您应该在 heroku 日志 (logplex) 中获得更多信息,如文档中所述。
  • 谢谢伙计。它有帮助。

标签: laravel heroku intervention


【解决方案1】:

Imagick 是一个需要安装在机器上的库。来自heroku docs

以下内置扩展已构建为“共享”并且可以 通过 composer.json 启用(在 括号):

将此答案中的代码添加到您的composer.json-https://stackoverflow.com/a/35660753/2460352

...
"require": {
     "ext-imagick": "*",
     ...
    }
}

【讨论】:

  • 那么你需要更强大的日志记录来识别你的问题devcenter.heroku.com/articles/php-logging这个链接有一个关于强制laravel输出错误的部分
  • 这有帮助。我在 Heroku 中更新了环境变量,发现 php 错误就在我的屏幕上。问题在于未安装 gd 库,尽管我已设置在 config/image.php 中使用 Imagick
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2018-05-20
  • 2015-10-21
  • 2015-02-09
  • 1970-01-01
  • 2019-01-16
  • 2017-01-28
  • 1970-01-01
相关资源
最近更新 更多