PHP/GD Bug: imageFilledEllipse Centered on Y=0
Posted by Chief on Nov 23, 2009 in Scripts, Tricks and Hacks
No Comments
I was drawing circles using PHP’s GD function imageFilledEllipse. I noticed that when I went to draw a circle having its center at $y=0,there would be a line missing at $y=1.
Here’s the work-around:
if( -1 <= $py && $py <= 1 ) { // Undocumented PHP bug when Y coordinate is zero. imageFilledEllipse($img,$px,$py,$X,$X,$color); imageFilledRectangle($img,$px-$halfX,$py-1,$px+$halfX,$py+1,$color); } else { imageFilledEllipse($img,$px,$py,$X,$X,$color); }
PHP Version:
PHP 4.3.9 (cgi) (built: Apr 1 2009 10:41:42) Copyright (c) 1997-2004 The PHP Group Zend Engine v1.3.0, Copyright (c) 1998-2004 Zend Technologies
$ yum search php-gd
php-gd.i386 4.3.9-3.26 installed Matched from: php-gd The php-gd package contains a dynamic shared object that will add support for using the gd graphics library to PHP.