|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #21524 Add imagesavealpha so that imagepng can output alpha channel
Submitted: 2003-01-08 13:22 UTC Modified: 2003-03-01 09:51 UTC
From: phpbugs at koimo dot net Assigned: pajoye (profile)
Status: Closed Package: Feature/Change Request
PHP Version: 4.3.0 OS: All
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 this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Bug Type:
From: phpbugs at koimo dot net
New email:
PHP Version: OS:


 [2003-01-08 13:22 UTC] phpbugs at koimo dot net
(Not sure whether this should be here or under GD related)

It would be useful if PHP had access to the gdSaveAlpha function in the GD library.

Using PHP 4.3.0 with bundled GD, there is currently no way I can see to prevent imagepng stripping the alpha channel of a truecolor image. The following script produces a white circle on a black background, rather than a semi-transparent circular 'hole':

$image = imagecreatetruecolor(200, 200);
imagealphablending($image, false);
imagefilledellipse($image, 100, 100, 150, 150, 0x3fffffff);
header('Content-type: image/png');

According to the GD change list at
this is the correct default behaviour since version 2.0.2 - there is a function gdSaveAlpha to turn on and off alpha output which appears to be present in the bundled GD in CVS but at the moment without any PHP wrapper. A PHP function imagesavealpha(resource image, bool savealpha) would allow alpha output when required without breaking any existing scripts.

-S. Haydon


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2003-01-09 17:24 UTC]
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at and the instructions on how to report
a bug at


This feature will be present in futur version of php (means not any upcoming bugfixes releases) using the bundled GD.

Thank's for your report,


 [2003-03-01 09:51 UTC]
This bug has been fixed in CVS.

In case this was a PHP problem, snapshots of the sources are packaged
every three hours; this change will be in the next snapshot. You can
grab the snapshot at
In case this was a documentation problem, the fix will show up soon at

In case this was a website problem, the change will show
up on the site and on the mirror sites in short time.
Thank you for the report, and for helping us make PHP better.

PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Apr 16 20:01:31 2024 UTC