php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #36050 imagecolorallocatealpha returns false
Submitted: 2006-01-17 14:44 UTC Modified: 2009-03-04 10:46 UTC
From: phpbug at phpandmore dot com Assigned: pajoye (profile)
Status: Closed Package: GD related
PHP Version: 5.1.2 OS: Windows NT LAPTOP 5.1 build 2600
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: phpbug at phpandmore dot com
New email:
PHP Version: OS:

 

 [2006-01-17 14:44 UTC] phpbug at phpandmore dot com
Description:
------------
When I try to allocate a transparent color as the background of an image, eg: the first color allocated, imagecolorallocatealpha returns false. I am using php 5.1.1, and gd bundled 2.0.28 compatable

Reproduce code:
---------------
$baseImage = imagecreate($_REQUEST['width'], $_REQUEST['height']);
if($trans = imagecolorallocatealpha($baseImage, 255, 255, 255, 63))
	echo 'good';
else
	echo 'bad';


Expected result:
----------------
good

Actual result:
--------------
bad

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-01-17 15:52 UTC] sniper@php.net
RTFM: $image=imagecreatetruecolor...

 [2006-01-17 16:11 UTC] pajoye@php.net
Something is wrong, not in GD but in the casting ops.
 [2006-01-17 16:24 UTC] pajoye@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php5.1-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php5.1-win32-latest.zip

Fixed in cvs.

You can now use ($trans === FALSE)

Note the "===" usage, zero being a perfectly valid color index, you have to check for both the type and the value (bool and false).
 [2006-01-25 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 [2009-03-04 10:29 UTC] pajoye@php.net
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Thu Jul 03 10:01:33 2025 UTC