Imagick在heroku上 - 可能吗? [英] Imagick on heroku - is it possible?

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

问题描述

我需要对jpeg图像执行一些操作 - Heroku的PHP GD不允许这样做。我已经读过Imagick可以使用,所以我重写了代码,将它推到了heroku中,然后... ...
$ b


PHP致命错误:Class'Imagick'not found in [...]


那么我做错了什么(代码在本地工作)? p>

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

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




如果它不适合你,那么大概Heroku的PHP web dynos默认没有安装它。你有两种选择:你可以找到一些令人费解的方式来将ImageMagick与你的应用程序本身打包在一起,例如将编译后的二进制文件添加到你的git源代码树中。或者,您可以修改 Heroku PHP构建包,这是一组设置规则部署应用程序之前的Web dyno,将ImageMagick与Apache和PHP本身一起安装。后一种方法更有可能。



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


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 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');

Is there any way of working with jpg on heroku?

解决方案

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

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.

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.

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

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