I intend to use a serverless php function to generate an image with TrueType fonts. In order to do that, I chose bref with Serverless framework and composer.
To process the image and include the text, I'm using imagettftext function from gd library. I ran php -S localhost:8000 index.php for local testing purposes. It worked fine, I got the output image as I expected it.
Thus I ran composer install --optimize-autoloader --no-dev and then serverless deploy to create a AWS Lamda function. However, when I called the deployed function's endpoint, it showed a Slim Application Error - without any detail:
A website error has occurred. Sorry for the temporary inconvenience.
So I took a look at AWS Cloudwatch logs and found this error message:
Message: Call to undefined function imagettftext()
Searching about this error, I found out it's often related to gd library missing. Then I compared phpinfo() from local test to the one from deployed function. Both have gd installed, the difference is that the local one has FreeType Support enabled.
Could you help me to find a way to enable this FreeType Support also for the serverless function? Is it possible to require this support through composer.json?
There's an issue open on GitHub at the moment regarding compiling PHP with freetype support, which explains the result you're seeing: https://github.com/brefphp/bref/issues/497.
GD needs to know about freetype as it's compiled into PHP, so I doubt you would be able to include it with composer
Related
Ipage says they are running ImageMagick 6.3.3 however, it is not running on the server and there is no way I can find how to enable it. They do not allow to configure any module from control panel.
I contacted support but they could not help saying, it is not 'their' product. Anybody can help setting up Imagick on ipage? I tried to edit php.ini file and reference to php_imagick.dll but that did not solve the problem.
iPage does not support Imagick in PHP
This is their official response after conctacting support
We have ImageMagick binaries. But it is not complied to PHP so IMAGICK
won't work. So, you will not be able to use IMAGICK as PHP built-in
class. You have to use the alternative "convert" utility. Please make
changes accordingly in the script so that it will work fine on our
servers.
So basically you have to use exec() in PHP to use the Imagemagick convert command. Also you cannot use convert command from a shell environment as for as I know.
But there is GD commands available on ipage and for the most part they would be enough for all graphic related functions. In fact in my case, I found that they were rather moreful.
The answer I got from iPage is that PHP Imagick is not available on the Essential Package. To get PHP Imagick I would need to sign up for VPS hosting which is more expensive. For now I am giong to ignore the recommendation from Wordpress to install PHP Imagick. I have installed the Wordpress "ImageMagick Engine" plugin and it is now working with no errors.
I use a php script that generates thumbnails. On my local server everything works but when I commit it the remote server throws 'Call to undefined function imageconvolution()'. I read something about GD library and saw that it is enabled on both servers (local and remote). Any suggestions?
Imageconvolution() was introduced in 5.1.0. Have you checked to see that the version running on the server is at least that version?
Edit: Ahhh, Ubunutu aye? That old chestnut.
Ubuntu doesn't compile with PHPs GD support due to security reasons. It uses generic GD. There is a function here that replicates the functionality, but it isn't anywhere near as fast apparently.
If you have proper access to the server, you can compile proper GD support into it. Instructions: http://www.howtoforge.com/recompiling-php5-with-bundled-support-for-gd-on-ubuntu
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.
I am new to php and this is my first ever php app.
My app includes the functionality to create image on runtime while adding text into it and thus for it is utilizing the function imagefttext().
My whole app was working fine on my previous server (godaddy) but recently ive transferred my app to heroku repository and now I am getting this error:
Fatal error: Call to undefined function imagefttext() …
For googling I found out that this function requires GD & freetype libraries, I do have GD support here but freetype support is missing.
Does Heroku doesn't support freetype lib?
Is it possible somehow that I can use freetype library over my new
server heroku?
If yes then how? Do I need to include few references in my code?
If that’s not possible, is there a way I can work around with adding
text to images without freetype?
Heroku does not support GD setup for jpg. Because of this I am not able to create collage out of profile pics, which are only in jpg format. I am having the same issue as the below link.
http://groups.google.com/group/heroku/browse_thread/thread/5f0b169272dd075f/5926d2e6eace859c?utoken=sizyOCkAAAD0zGxoh6dI3732ocaO_CKc0UdN2a4MLXn0dn7f9oF9dw34Femrnx-0ZHcOkI9yXY0
How do I resolve this issue?
My alternative was to use imagick.so extension instead. See my reply #stackoverflow here for instruction how to get this extension up and running quickly. Let me know if this works (the few basic functions I tried are ok).
The official buildpack from Heroku doesn't list PHP. Strange.
Heroku does support ImageMagick. I ran in to the GD/JPG problem hosting a WordPress site, but it was easily fixed by installing the imagemagick-engine plugin. Using it from the command line works with the path /usr/bin . The PHP module is not installed.