php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #40601 imagesavealpha() has opposite effect on transparent color
Submitted: 2007-02-23 03:04 UTC Modified: 2007-02-23 09:40 UTC
From: seth at pricepages dot org Assigned: pajoye (profile)
Status: Not a bug Package: GD related
PHP Version: 5.2.1 OS: Mac 10.4
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: seth at pricepages dot org
New email:
PHP Version: OS:

 

 [2007-02-23 03:04 UTC] seth at pricepages dot org
Description:
------------
The function imagesavealpha() has an opposite effect on the 
output image if the color is marked as transparent. For 
example, the code below should always create a clear image. 
But it renders as black.

The interesting thing is that if you remove the imagesavealpha
, the image renders as expected (clear).

Reproduce code:
---------------
<?php
$img = imagecreatetruecolor(100,100);

$trans = imagecolorresolve($img,0,0,0);
imagecolortransparent($img, $trans);
imagealphablending($img, false);
imagefilledrectangle($img, 0,0, 100,100, $trans);

//Has opposite affect
imagesavealpha($img,true);

header('Content-Type: image/png');
imagepng($img);
?>

Expected result:
----------------
nothing (a clear image)

Actual result:
--------------
a solid black image

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-02-23 09:40 UTC] pajoye@php.net
Transparent color and alpha cannot work together when you save a file. PNG supports one or another not both (PNG is also the only format supporting alpha).

You will get a warning/error in libpng if you try to do the same calls (for example in C).

not a bug > bogus.

 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Wed Jul 30 09:00:03 2025 UTC