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?
A simpler approach is to install ImageMagick using composer.json
, as explained here: https://devcenter.heroku.com/articles/php-support#using-optional-extensions
You just need to include imagick
in the require
section and update composer:
{
...
"require": {
"ext-imagick": "*",
...
}
}
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With