Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

Phalcon\Image\Adapter\Gd throwing an exception for the text function

I have the following in my code:

use Phalcon\Image\Adapter\GD as Image;
    $imagePath = BASE_DIR . '/public/img/map-icons/' . $client->getId() . '/' . $file;
    $image = new Image($imagePath);
    $fontFile = $this->getFontPath();
    $image->text($text, $x, $y, 1, '#FFFFFF', $fontSize, $fontFile);

Under Phalcon 1.3.4 and php 5.4.45 it works fine, but when I migrated the application to a new server running Phalcon version 3.4.5 and php 7.3.17 the $image->text($text, $x, $y, 1, '#FFFFFF', $fontSize, $fontFile); is giving the following error:

Project raised exception class Phalcon\lmage\Exception with message "Call to imagettfbboxO failed" at gd.zep, line 357

The literal values being passed to $image->text(..) are as follows:

$image->text(H, 9, 20, 1, '#FFFFFF', 11, '/var/www/vhosts/');

I have googled high and low but have found no mention of this error.

What could be causing this?

Can anyone help me?

Thanks, Nick

edited 28d ago

When I try the example for imagettfbbox given on the page here the emaple works and shows diagonal text in a white box, so I don't think there is an issue with imagettfbbox. However, the parameters shown for imagettfbbox in the php manual are as follows: imagettfbbox ( float $size , float $angle , string $fontfile , string $text ), but for phalcon gd text() they are text (mixed $text, [mixed $offsetX], [mixed $offsetY], [mixed $opacity], [mixed $color], [mixed $size], [mixed $fontfile]). Could it be that gd text() is using imagettfbbox incorrectly for Phalcon 3.4.5?

I have also asked on StackOverflow here


This is a bug but won't be fixed in v3.4.5: