I'm trying to use image intervention in my Jobs Controller. First, "image source not readable error" came out. But then I fixed by adding storage_path. Now it's showing this error:
Call to undefined function Intervention\Image\Gd\imagettfbbox()
This happen when I want to write font on an image. These are my codes:
$img->text($line, $x_subject, $y, function($font) use ($font_size_subject, $font_path){
$font->file(storage_path($font_path));
$font->size($font_size_subject);
$font->color('#000000');
$font->align('center');
$font->valign('middle');
});
There is no error when I try to use it in a normal controller. This error just shows up when I'm using image intervention in Jobs controller.
Is there any way I can solve this? Thank you
When you say it works in a normal controller, you mean when you call it from http protocol (browser/postman/etc..)
You most likely have two PHP configuration (as of standard); one for the web (FPM) and one for the console (CLI).
The reason you are getting the error only when you are using a job controller is because the GD extension is missing in your PHP CLI configuration.
you can check in the console if the GD extension is enabled with php -m |grep gd
. if it is enabled, you should have something like this
$ php -m |grep gd
12:gd
if you dont get the second line, the you need to enable the extension in the right ini file (the one for the CLI).
if you dont know where it is, try running php -i | grep 'Configuration File'
, you should get something like this:
Configuration File (php.ini) Path => /etc/php/7.x/cli
Loaded Configuration File => /etc/php/7.x/cli/php.ini
Hope this helps
------------Edit---------------
according to PHP.net imagettftext.
This function requires both the GD library and the » FreeType library.
you must be missing the FreeType library in the CLI configuration.
Since it's a shared host, it's the responsibility of the provider to help resolve this issue.