Doc #53175 [NEW]: Confusing (ambiguous) imagecolorallocate return value when color is black

From: Date: Tue, 26 Oct 2010 20:50:19 +0000
Subject: Doc #53175 [NEW]: Confusing (ambiguous) imagecolorallocate return value when color is black
Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-5423@lists.php.net to get a copy of this message
From: Operating system: Windows 7/2003 Server PHP version: 5.2.14 Package: Documentation problem Bug Type: Documentation Problem Bug description:Confusing (ambiguous) imagecolorallocate return value when color is black Description: ------------ According to the online documentation the imagecolorallocate function returns "A color identifier or FALSE if the allocation failed". The confusion comes when I try to allocate black color, passing 0x0 to all the three color components. The function always returns 0, which means FALSE, but it looks like the identifier is valid. Future use of it in other gd functions leads to successful results. I also noticed in the online documentation that in prior to 5.1.3 versions of PHP this function returns -1 if the allocation failed, so it is eather a problem in the documentation or bug in the gd extension I am using. Test script: --------------- Code: header("Content-type: image/png"); $im = imagecreatetruecolor(300, 100); $font_color = imagecolorallocate($im, 0, 0, 0); // Black $bg_color = imagecolorallocate($im, 255, 255, 0); // Yellow imagefill($im, 0, 0, $bg_color); imagestring($im, 10, 40, 40, "font color identifier is: $font_color", $font_color); imagepng($im); imagedestroy($im); Output: Yellow image with black colored string: "font color identifier is: 0" Expected result: ---------------- The imagecolorallocate function should not return zero value for valid color identifiers or the documentation should be changed. -- Edit bug report at http://bugs.php.net/bug.php?id=53175&edit=1 -- Try a snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=53175&r=trysnapshot52 Try a snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=53175&r=trysnapshot53 Try a snapshot (trunk): http://bugs.php.net/fix.php?id=53175&r=trysnapshottrunk Fixed in SVN: http://bugs.php.net/fix.php?id=53175&r=fixed Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=53175&r=needdocs Fixed in release: http://bugs.php.net/fix.php?id=53175&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=53175&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=53175&r=needscript Try newer version: http://bugs.php.net/fix.php?id=53175&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=53175&r=support Expected behavior: http://bugs.php.net/fix.php?id=53175&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=53175&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=53175&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=53175&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=53175&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=53175&r=dst IIS Stability: http://bugs.php.net/fix.php?id=53175&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=53175&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=53175&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=53175&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=53175&r=mysqlcfg

« previous php.doc.bugs (#5423) next »