0

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?

Gabriel Ataide
  • 37
  • 1
  • 10

1 Answers1

0

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

nealio82
  • 2,611
  • 1
  • 17
  • 19