Re: [PHP-DEV] PHP 8.1.0RC6 available for testing

  116408
November 16, 2021 12:11 come@chilliet.eu (=?ISO-8859-1?Q?C=F4me?= Chilliet)
Hello,

I have a difference in behavior between PHP 8.1 RC6 and my system PHP for the function imagettfbbox.
It is hard to know if this is a problem with 8.1 really because I had to download and build imagick through pecl to be able to run this.


  int(1)
  [1]=>
  int(0)
  [2]=>
  int(8)
  [3]=>
  int(0)
  [4]=>
  int(8)
  [5]=>
  int(-12)
  [6]=>
  int(1)
  [7]=>
  int(-12)
}
$ php ~/dev/test-freetype.php
array(8) {
  [0]=>
  int(0)
  [1]=>
  int(1)
  [2]=>
  int(10)
  [3]=>
  int(1)
  [4]=>
  int(10)
  [5]=>
  int(-12)
  [6]=>
  int(0)
  [7]=>
  int(-12)
}

As you can see the resulting bounding box is not the same, for the same font. This messes up our avatar generation, which ends up a few pixels wrong on the centering of the initial in the image.

Does anyone knows where this can come from, and if by changing how I build/link imagick I can get the same result on both binaries?

Côme
  116410
November 16, 2021 12:40 cmbecker69@gmx.de ("Christoph M. Becker")
On 16.11.2021 at 13:11, Côme Chilliet wrote:

> I have a difference in behavior between PHP 8.1 RC6 and my system PHP for the function imagettfbbox. > It is hard to know if this is a problem with 8.1 really because I had to download and build imagick through pecl to be able to run this.
imagettfbbox() is part of ext/gd which is a bundled extension. It has nothing to do with imagick (besides both are for image manipulation).
> $font = '/usr/share/fonts/truetype/noto/NotoSans-Regular.ttf'; > var_dump(imagettfbbox(12, 0, $font, 'E')); > > The result for running this is: > $ ~/dev/php-src-git/sapi/cli/php ~/dev/test-freetype.php > array(8) { > [0]=> > int(1) > [1]=> > int(0) > [2]=> > int(8) > [3]=> > int(0) > [4]=> > int(8) > [5]=> > int(-12) > [6]=> > int(1) > [7]=> > int(-12) > } > $ php ~/dev/test-freetype.php > array(8) { > [0]=> > int(0) > [1]=> > int(1) > [2]=> > int(10) > [3]=> > int(1) > [4]=> > int(10) > [5]=> > int(-12) > [6]=> > int(0) > [7]=> > int(-12) > } > > As you can see the resulting bounding box is not the same, for the same font. This messes up our avatar generation, which ends up a few pixels wrong on the centering of the initial in the image. > > Does anyone knows where this can come from, and if by changing how I build/link imagick I can get the same result on both binaries?
This might be due to different libfreetype, libgd or libraqm versions (or possibly libraqm wasn't enabled for one of the builds), or because one build used system libgd and the other used the bundled GD. -- Christoph M. Becker
  116412
November 16, 2021 13:48 come@chilliet.eu (=?ISO-8859-1?Q?C=F4me?= Chilliet)
Le mardi 16 novembre 2021, 13:40:30 CET Christoph M. Becker a écrit :
> On 16.11.2021 at 13:11, Côme Chilliet wrote: > > I have a difference in behavior between PHP 8.1 RC6 and my system PHP for the function imagettfbbox. > > It is hard to know if this is a problem with 8.1 really because I had to download and build imagick through pecl to be able to run this. > > imagettfbbox() is part of ext/gd which is a bundled extension. It has > nothing to do with imagick (besides both are for image manipulation).
Thank you for the clarification, I got lost in all theses libraries…
> This might be due to different libfreetype, libgd or libraqm versions > (or possibly libraqm wasn't enabled for one of the builds), or because > one build used system libgd and the other used the bundled GD.
The PHP from my system is 7.4 and says: $ php --info|grep -i freetype -i FreeType Support => enabled FreeType Linkage => with freetype $ php --info|grep -i gd -i /etc/php/7.4/cli/conf.d/20-gd.ini, gd GD Support => enabled GD headers Version => 2.2.5 GD library Version => 2.2.5 gd.jpeg_ignore_warning => 1 => 1 The one I built says: $ ~/dev/php-src-git/sapi/cli/php --info|grep -i freetype Configure Command => './configure' '--with-ldap' '--with-ldap-sasl' '--with-zip' '--with-curl' '--with-openssl' '--with-zlib' '--enable-mbstring' '--enable-pcntl' '--enable-intl' '--with-password-argon2' '--with-freetype' '--with-jpeg' '--enable-gd' '--with-imagick' FreeType Support => enabled FreeType Linkage => with freetype FreeType Version => 2.10.1 $ ~/dev/php-src-git/sapi/cli/php --info|grep -i gd Configure Command => './configure' '--with-ldap' '--with-ldap-sasl' '--with-zip' '--with-curl' '--with-openssl' '--with-zlib' '--enable-mbstring' '--enable-pcntl' '--enable-intl' '--with-password-argon2' '--with-freetype' '--with-jpeg' '--enable-gd' '--with-imagick' gd GD Support => enabled GD Version => bundled (2.1.0 compatible) gd.jpeg_ignore_warning => 1 => 1 So it seems the one I built used a bundled older version of GD? How should I change my configure line to use the same GD as the other one? Côme
  116413
November 16, 2021 13:57 cmbecker69@gmx.de ("Christoph M. Becker")
On 16.11.2021 at 14:48, Côme Chilliet wrote:

> GD Support => enabled > GD Version => bundled (2.1.0 compatible) > gd.jpeg_ignore_warning => 1 => 1 > > So it seems the one I built used a bundled older version of GD? How should I change my configure line to use the same GD as the other one?
While it still states "2.1.0 compatible", it is more like "2.3 compatible", but we didn't change that, because the goal is eventually to get rid of the bundled libgd. Anyhow, use `--enable-gd --with-external-gd`; see <https://www.php.net/manual/en/image.installation.php>. You can also check the configure line of the 7.4 build via php --info | grep 'Configure Command'. And well, we're on the wrong mailing list here. :) -- Christoph M. Becker