skip to Main Content

I have the following in my code:

use PhalconImageAdapterGD 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 PhalconlmageException 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');

When I try the example for PHP’s imagettfbbox given on the page here https://www.php.net/manual/en/function.imagettfbbox.php the example works and shows diagonal text in a white box enter image description here, 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])

3

Answers


  1. Chosen as BEST ANSWER

    It's a bug in Phalcon 3.4.5. See https://github.com/phalcon/cphalcon/issues/15188. The lowest version it will be fixed for is 4.1.


  2. There must be some issue with the gd installation on your host and/or the font file.

    Internally, text() calls PHP’s imagettfbbox. If you create as simple PHP script that will use this method with your parameters, you could get a lot more information regarding what is going on

    Login or Signup to reply.
  3. I advise against using Phalcon’s GD wrapper.

    It produces low quality image at large size, because it uses imagecopyresized instead of imagecopyresampled.

    I find Python/PILLOW to be MUCH simpler to use and produce the correct result.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search