ID: 21560 Comment by: kyle at putnamcabinets dot com Reported By: ljpersson at hotmail dot com Status: Assigned Bug Type: GD related Operating System: SusE 8.0,SuSE 8.2 PHP Version: 4.3.1-dev, 4.3.2RC2, 4.3.2RC3 Assigned To: pajoye New Comment:
I also experience the problem with PHP 4.3.2 and bundled GD version '2.0.12 compatible'. Recompiled with Debian package version (2.0.12-2... damn!) and same problem (obviously). It seems to be some how proportional to the angle of the text; smaller angles yield more accuracy. My implementation: <? $res = imagecreatetruecolor(400, 400); $white = imagecolorallocate($res, 0xff, 0xff, 0xff); $red = imagecolorallocate($res, 0xcc, 0x00, 0x00); $blue = imagecolorallocate($res, 0x00, 0x00, 0xcc); imagefill($res, 0, 0, $white); for ($angle = 0; $angle < 360; $angle += 60) { $wrong1 = imagettftext($res,20,$angle,200,200,$blue, "/usr/share/fonts/truetype/Courier_New.ttf", "ABCDEF 12345"); $t = imagettfbbox(20, $angle, "/usr/share/fonts/truetype/Courier_New.ttf", "ABCDEF 12345"); $wrong2 = array(200+$t[0],200+$t[1],200+$t[2], 200+$t[3],200+$t[4],200+$t[5],200+$t[6],200+$t[7]); imagepolygon($res,$wrong2,count($wrong2)/2,$red); imagepolygon($res,$wrong1,count($wrong1)/2,$red); } header("Content-type: image/png"); imagepng($res); ?> Previous Comments: ------------------------------------------------------------------------ [2003-06-18 03:03:12] guno at guno dot nl I'm experiencing the same problem, using php 4.3.2 with GD 2.0.15 Normal text (with no rotation) results in a correct bounding box, but as soon as I rotate the text, it goes wrong, no matter which font I use. Here's a sample code which displays a text with it's bounding box at 0, 90, 180 and 170 degrees: <?php $image=imagecreate(500, 500); $imagedum=imagecreate(500, 500); $color1=imagecolorallocate($image, 0xff, 0xff, 0xff); $color2=imagecolorallocate($image, 0x3f, 0x3f, 0x3f); $color3=imagecolorallocate($image, 0xff, 0x00, 0x00); for ($angle=0; $angle<360; $angle+=90) { $text="ABCpqrs"; $font = "./verdana.ttf"; // Draw the text into the image: $result=imagettftext($imagedum, 30, $angle, 250, 250, $color2, $font, $text); imagettftext($image, 30, $angle, 250, 250, $color2, $font, $text); // Draw the bounding-box into the image: imageline($image, $result[0], $result[1], $result[2], $result[3], $color3); imageline($image, $result[2], $result[3], $result[4], $result[5], $color3); imageline($image, $result[4], $result[5], $result[6], $result[7], $color3); imageline($image, $result[6], $result[7], $result[0], $result[1], $color3); } // Draw the image to the screen: header("Content-Type: image/jpeg"); imagejpeg($image); imagedestroy($image); imagedestroy($imagedum); ?> ------------------------------------------------------------------------ [2003-05-16 19:37:07] ljpersson at hotmail dot com Just checked with 4.3.2RC3 and the problem still exists. ------------------------------------------------------------------------ [2003-05-05 13:23:02] ljpersson at hotmail dot com This problem still exists in 4.3.2RC2. This returns yet another set of (wrong) coordinates for the bounding box. With 4.3.2RC2 (Compiled on SuSE 8.2) gives the following wrong return array: Array ( [0] => -1 [1] => 14 [2] => -1 [3] => -146 [4] => -17 [5] => -146 [6] => -17 [7] => 14 ) Which is again different from what was returned in 4.3.1 ------------------------------------------------------------------------ [2003-02-27 08:47:02] [EMAIL PROTECTED] don't forget.. :) ------------------------------------------------------------------------ [2003-02-26 19:55:33] [EMAIL PROTECTED] I confirm it too. I found where is the problem. I will try to fix it before the next release. ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at http://bugs.php.net/21560 -- Edit this bug report at http://bugs.php.net/?id=21560&edit=1