From:             laszlo dot janszky at gmail dot com
Operating system: windows xp
PHP version:      5.2.6
PHP Bug Type:     GD related
Bug description:  Imagecolorallocate,imagettftext,rand combined bug

Description:
------------
I'm calling imagecolorallocate and imagettftext functions with random
parameters in a loop, but after some call the imagecolorallocate function
returns FALSE. I checked the random parameters, but nothing strange about
them.
I think the bug is associated with the rand function, because the more I
call the rand function, the earlier the bug comes in loop. If I delete the
rand from the 5 times I call, and replace it with constant number, the bug
comes later in cycle. With this settings it's about character 'w', but not
on a constant place, somtimes 'x' or 'y'.


Reproduce code:
---------------
                $text=str_split('0123456789abcdefghijklmnopqrstvwxyz',1);
                $image=imagecreate(600,50);
                $bgcolor=imagecolorallocate($image,0,200,130);
                foreach($text as $char)
                {
                        $r=rand(0,30);
                        $b=255-rand(0,30);
                        $g=138+rand(-15,15);
                        
                        $a=rand(0,10);
                        $l=15+$len*15;
                        $t=35+rand(-5,5);
                        
                        $s=20+rand(-2,2);
                        
                        
imagettftext($image,$s,$a,$l,$t,imagecolorallocate($image,$r,$b,$g),'xfont.ttf',$char);
                        $len++;
                }
                header("Expires: Mon,26 Jul 1997 05:00:00 GMT");
                header("Last-Modified: ".gmdate("D,d M Y H:i:S")." GMT");
                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");
                imagepng($image);
                imagedestroy($image);

Expected result:
----------------
I expect to get an image with characters
'0123456789abcdefghijklmnopqrstvwxyz' one after the other with
different(random) angles and colour.

Actual result:
--------------
I got an image with characters '0123456789abcdefghijklmnopqrstvw', so not
the complete character list. And didn't get any error messages or notices
with error_reporting(2047).

-- 
Edit bug report at http://bugs.php.net/?id=46466&edit=1
-- 
Try a CVS snapshot (PHP 5.2):        
http://bugs.php.net/fix.php?id=46466&r=trysnapshot52
Try a CVS snapshot (PHP 5.3):        
http://bugs.php.net/fix.php?id=46466&r=trysnapshot53
Try a CVS snapshot (PHP 6.0):        
http://bugs.php.net/fix.php?id=46466&r=trysnapshot60
Fixed in CVS:                        
http://bugs.php.net/fix.php?id=46466&r=fixedcvs
Fixed in CVS and need be documented: 
http://bugs.php.net/fix.php?id=46466&r=needdocs
Fixed in release:                    
http://bugs.php.net/fix.php?id=46466&r=alreadyfixed
Need backtrace:                      
http://bugs.php.net/fix.php?id=46466&r=needtrace
Need Reproduce Script:               
http://bugs.php.net/fix.php?id=46466&r=needscript
Try newer version:                   
http://bugs.php.net/fix.php?id=46466&r=oldversion
Not developer issue:                 
http://bugs.php.net/fix.php?id=46466&r=support
Expected behavior:                   
http://bugs.php.net/fix.php?id=46466&r=notwrong
Not enough info:                     
http://bugs.php.net/fix.php?id=46466&r=notenoughinfo
Submitted twice:                     
http://bugs.php.net/fix.php?id=46466&r=submittedtwice
register_globals:                    
http://bugs.php.net/fix.php?id=46466&r=globals
PHP 4 support discontinued:          http://bugs.php.net/fix.php?id=46466&r=php4
Daylight Savings:                    http://bugs.php.net/fix.php?id=46466&r=dst
IIS Stability:                       
http://bugs.php.net/fix.php?id=46466&r=isapi
Install GNU Sed:                     
http://bugs.php.net/fix.php?id=46466&r=gnused
Floating point limitations:          
http://bugs.php.net/fix.php?id=46466&r=float
No Zend Extensions:                  
http://bugs.php.net/fix.php?id=46466&r=nozend
MySQL Configuration Error:           
http://bugs.php.net/fix.php?id=46466&r=mysqlcfg

Reply via email to