php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #34733 imageFTText x coordinate not working
Submitted: 2005-10-04 16:37 UTC Modified: 2005-10-04 21:19 UTC
From: mhinck at suscom dot net Assigned: pajoye (profile)
Status: Closed Package: GD related
PHP Version: 5.0.5 OS: Fedora Core 2
Private report: No CVE-ID: None
 [2005-10-04 16:37 UTC] mhinck at suscom dot net
Description:
------------
After upgrading from 5.0.2 to 5.0.5 the x coordinate in the imageFTText is doing nothing.  All other arguments work as expected but the x coordinate is ignored.  Example uses arial but tried with many fonts with same result.  GD is version 2.0.28.  Following config ran without issue:

./configure --with-apxs2=/usr/local/apache2/bin/apxs --with-mysqli=/usr/local/mysql/bin/mysql_config --with-mysql=/usr/local/mysql/  --with-t1lib=/usr/local/lib --enable-fast-cgi --enable-magic-quotes --with-openssl --enable-sockets --enable-debug --with-zlib  --with-cyrus --enable-exif --with-gd=/usr --with-freetype-dir=/usr/local --enable-calendar --with-gettext --with-xml --enable-dom --with-iconv --enable-mbstring --with-mbstring=all --with-kerberos --with-mcrypt --with-cyrus --with-imap --with-imap-ssl --with-mcal=/usr/lib  --with-ldap --with-ldap-sasl


Reproduce code:
---------------
<?php

$im = LoadPNG("blank.png"); //A straight white png file.
imagecolortransparent ($im, imagecolorat ($im, 0, 0));
$font = "/usr/X11R6/lib/X11/fonts/TTF/arial.ttf";
$txtcr = imagecolorallocate($im, 0, 0, 0); ;
$tbb = imageFTText ($im, 12, 0, 50, 25, $txtcr, $font, "testing", array());

header ("Content-type: image/png");
imagePNG($im);
imagedestroy ($im);

function LoadPNG ($imgname) {
   $im = @imagecreatefrompng ($imgname); /* Attempt to open */
   if (!$im) { /* See if it failed */
       $im  = imagecreate (150, 30); /* Create a blank image */
       $bgc = imagecolorallocate ($im, 255, 255, 255);
       $tc  = imagecolorallocate ($im, 0, 0, 0);
       imagefilledrectangle ($im, 0, 0, 150, 30, $bgc);
       /* Output an errmsg */
       imagestring ($im, 1, 5, 5, "Error loading $imgname", $tc);
   }
   return $im;
}
?>

Expected result:
----------------
The text "testing" 50 pixels from the left of the screen.

Actual result:
--------------
The text "testing" flush to the left.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-10-04 18:28 UTC] sniper@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php5-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php5-win32-latest.zip


 [2005-10-04 21:09 UTC] pajoye@php.net
And provide a short script without extern data.

In your case 3-4 lines, create the image draw some text save the image.

Please try with the bundled GD ("./configure --with-gd") as well.
 [2005-10-04 21:19 UTC] mhinck at suscom dot net
The 5.1 snapshot you linked worked.  I had only tried the 5.0.  Thanks.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat May 04 18:01:32 2024 UTC