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 staging.api.my-domain.com 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/staging.api.mydomain.com/src/fonts/arialbd.ttf');

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 https://www.php.net/manual/en/function.imagettfbbox.php 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 https://stackoverflow.com/questions/64541937/phalcon-image-adapter-gd-throwing-an-exception-for-the-text-function



156
Accepted
answer

This is a bug but won't be fixed in v3.4.5: https://github.com/phalcon/cphalcon/issues/15188