Heroku 上的 Imagick - 有可能吗? [英] Imagick on heroku - is it possible?

查看:29
本文介绍了Heroku 上的 Imagick - 有可能吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要对 jpeg 图像执行一些操作 - Heroku 的 PHP GD 不允许这样做.我已经读到 Imagick 是可能的,所以我重写了代码,将它推送到 heroku 并......

I need to do some actions on jpeg images - Heroku's PHP GD does not allow that. I've read that it is possible with Imagick, so i rewritten the code, pushed it to heroku and...

PHP 致命错误:在 [...] 中找不到类Imagick"

PHP Fatal error: Class 'Imagick' not found in [...]

所以我做错了什么(代码在本地工作)?

So am I doing something wrong(code works locally)?

$tlo = new Imagick();
$tlo->newImage(640, 480, new ImagickPixel('white'));
$tlo->setImageFormat('jpg');

有没有办法在heroku上使用jpg?

Is there any way of working with jpg on heroku?

推荐答案

ImageMagick,一个命令行实用程序和编程库,必须安装在系统上才能让 Imagick 工作.

ImageMagick, a command-line utility and programming library, must be installed on the system for Imagick to work.

如果它不适合你,那么大概 Heroku 的 PHP web dynos 默认没有安装它.您有两个选择:您可以找到一些复杂的方法将 ImageMagick 与您的应用程序本身打包在一起,例如通过将编译后的二进制文件添加到您的 git 源代码树中.或者,你可以修改Heroku PHP buildpack,这是一套设置规则在部署应用程序之前启动 Web dyno,以安装 ImageMagick 以及 Apache 和 PHP 本身.后一种方法更有可能奏效.

If it's not working for you, then presumably Heroku's PHP web dynos do not have this installed by default. You have two options: you can find some convoluted way to package ImageMagick with your application itself, for instance by adding compiled binaries to your git source tree. Or, you can modify the Heroku PHP buildpack, which is the set of rules that sets up the web dyno before your application is deployed, to install ImageMagick along with Apache and PHP itself. The latter approach is more likely to work.

修改 buildpack 后,使用命令行 Heroku 工具(--buildpack 选项)将应用程序更改为指向 buildpack fork 并重新部署.

Once you've modified the buildpack, change your application to point to your buildpack fork with the command-line Heroku tools (the --buildpack option) and redeploy.

这篇关于Heroku 上的 Imagick - 有可能吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆