Search code examples
laravelinterventionimagettftext

imagettfbbox(): Problem doing text layout using Laravel Intervention/Image


I am using Intervention/Image to generate some images with Laravel. Something like this:

$img->text('test', 300, 30, function ($font) {
            $font->file(public_path('assets/fonts/montserrat.ttf'));
            $font->size(30);
            $font->color('#000');
            $font->align('center');
            $font->valign('top');
            $font->angle(0);
        });

It worked till now...on the production server everything is alright but in my local server I get "imagettfbbox(): Problem doing text layout" everytime I am generating the image. I can't seem to find any answer to this problem.

I tried matching the PHP version with the one from my server (7.2), I previously had 7.4 on local but that doesnt seem to change anything :(

Would very much appreciate if someone could help me with this!


Solution

  • For anyone having this problem, I did something wrong, it seems like if the text value is null the image library does not know how to handle it, I had some cases in which the text was null and this caused the error.