Edit report at http://bugs.php.net/bug.php?id=51315&edit=1

 ID:               51315
 Updated by:       paj...@php.net
 Reported by:      administrateur at exinsidephp dot com
 Summary:          imagettfbbox randomly don't work
-Status:           Open
+Status:           Assigned
 Type:             Bug
 Package:          GD related
 Operating System: Debian GNU/Linux 5.0
 PHP Version:      5.3.2
-Assigned To:      
+Assigned To:      geissert

 New Comment:

Raphael, can you take a look at this one please?


Previous Comments:
------------------------------------------------------------------------
[2010-03-23 14:52:53] administrateur at exinsidephp dot com

So I have find the origin of the problem : "GCC".



This problem appear if you compile PHP 5.3.2 width GCC 4.3.2 on Debian
32 bits. For fix the problem you must compile PHP 5.3.2 width GCC 4.1.2.

------------------------------------------------------------------------
[2010-03-19 16:36:19] administrateur at exinsidephp dot com

rechange title

------------------------------------------------------------------------
[2010-03-19 16:35:50] administrateur at exinsidephp dot com

So I have add debug line and i find origin of bug :



View my previous script an modify width this line :



$tab =
imagettfbbox(8,0,Config::getCons('PATH_CACHE').'font/verdana.TTF',
$texte);

$text_x = (55-($tab[2]-$tab[6]))/2;

$text_y = (15-($tab[1]-$tab[5]))/2+9;



file_put_contents(Config::getCons('PATH_CACHE').'log_font.txt', $text.'
x:'.$text_x.' y:'.$text_y.'
imagbox:'.json_encode($tab)."\n",FILE_APPEND);





The result : 



 x:12 y:12.5 imagbox:[-1,-1,30,-1,30,-9,-1,-9]

 x:33554459 y:12.5
imagbox:[-1,-1,-33554433,-1,-33554433,-9,33554430,-9]

 x:33554459 y:12.5
imagbox:[-1,-1,-33554433,-1,-33554433,-9,33554430,-9]

 x:33554459 y:12.5
imagbox:[-1,-1,-33554433,-1,-33554433,-9,33554430,-9]

 x:12 y:12.5 imagbox:[-1,-1,30,-1,30,-9,-1,-9]

 x:12 y:12.5 imagbox:[-1,-1,30,-1,30,-9,-1,-9]

 x:12 y:12.5 imagbox:[-1,-1,30,-1,30,-9,-1,-9]

 x:12 y:12.5 imagbox:[-1,-1,30,-1,30,-9,-1,-9]

 x:12 y:12.5 imagbox:[-1,-1,30,-1,30,-9,-1,-9]

 x:12 y:12.5 imagbox:[-1,-1,30,-1,30,-9,-1,-9]

 x:33554459 y:12.5
imagbox:[-1,-1,-33554433,-1,-33554433,-9,33554430,-9]

 x:12 y:12.5 imagbox:[-1,-1,30,-1,30,-9,-1,-9]



So the problem is located on imagettfbbox funtion, it give wrong value
for x position.

------------------------------------------------------------------------
[2010-03-19 16:26:47] administrateur at exinsidephp dot com

Change title of bug

------------------------------------------------------------------------
[2010-03-17 20:55:28] administrateur at exinsidephp dot com

Description:
------------
Hi,



I have ugraded PHP 5.2 to PHP 5.3.2 on my Debian server and I have found
a bug width ths function imagettfbbox.



Sometimes the text don't show on the image generated :



http://www.exinsidephp.com/cache/example.png



If I refresh the page (Ctrl+F5) another image don't display the text :



http://www.exinsidephp.com/cache/example2.png



Any error on PHP Blog, any error on syslog or kernel log... I haven't
find any trace of error. Someone have the same issue ?



The PHP Package come from http://www.dotdeb.org/ website. The list of
modules installed (dpkg -l | grep php5) :



ii  libapache2-mod-php5 5.3.2-0.dotdeb.1                                
                               

ii  php5                                 5.3.2-0.dotdeb.1               
                                                

ii  php5-cli                                5.3.2-0.dotdeb.1            
                                                   

ii  php5-common                             5.3.2-0.dotdeb.1            
                                                   

ii  php5-curl                               5.3.2-0.dotdeb.1            
                                                   

ii  php5-dev                                5.3.2-0.dotdeb.1            
                                                   

ii  php5-gd                                 5.3.2-0.dotdeb.1            
                                                   

ii  php5-geoip                              5.3.2-0.dotdeb.1            
                                                   

ii  php5-imagick                            5.3.2-0.dotdeb.1            
                                                   

ii  php5-imap                               5.3.2-0.dotdeb.1            
                                                   

ii  php5-mcrypt                             5.3.2-0.dotdeb.1            
                                                   

ii  php5-mysql                              5.3.2-0.dotdeb.1            
                                                   

ii  php5-suhosin                            5.3.2-0.dotdeb.1            
                                                   

ii  php5-xcache                             5.3.2-0.dotdeb.1            
                                                   

Test script:
---------------
header('Cache-Control: no-store, no-cache, must-revalidate');

header('Cache-Control: post-check=0, pre-check=0', false);

header('Pragma: no-cache');

header('Content-Type: image/png');

                

$image = imagecreate(55,15);

imagecolorallocate($image, 0,0,0);



if($get->getValue('temp2'))

        $texte = $get->getValue('temp1').'/'.$get->getValue('temp2').' °C';

else

        $texte = $get->getValue('temp1').' °C';



$tab =
imagettfbbox(8,0,Config::getCons('PATH_CACHE').'font/verdana.TTF',
$texte);

$text_x = (55-($tab[2]-$tab[6]))/2;

$text_y = (15-($tab[1]-$tab[5]))/2+9;



//$color = imagecolorallocate($image, 2,119,186);

$color = imagecolorallocate($image, 255,255,255);

imagettftext($image,8,0,$text_x,$text_y,$color,Config::getCons('PATH_CACHE').'font/verdana.TTF',$texte);



imagepng($image);



------------------------------------------------------------------------



-- 
Edit this bug report at http://bugs.php.net/bug.php?id=51315&edit=1

Reply via email to