php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #26928 imagecreatetruecolor black background makes alpha transparancy unusable
Submitted: 2004-01-15 23:31 UTC Modified: 2011-02-05 03:15 UTC
Votes:13
Avg. Score:4.8 ± 0.6
Reproduced:13 of 13 (100.0%)
Same Version:8 (61.5%)
Same OS:4 (30.8%)
From: michel at breggen dot nl Assigned:
Status: Not a bug Package: GD related
PHP Version: Irrelevant OS: RedHat Linux
Private report: No CVE-ID: None
 [2004-01-15 23:31 UTC] michel at breggen dot nl
Description:
------------
when creating a new truecolor image, the image gets set with a black background. This makes it unusable to blend alpha transparant png's onto it (for creating transparant thumbnails for example). Normally you would have a blank (all transparant) image when creating a new image because no data has been added to it.



Reproduce code:
---------------
$img = imagecreatetruecolor(50,50);
header ("Content-type: image/x-png");
imagepng($img);
imagedestroy($img);


Expected result:
----------------
a transparant 50x50 png image.

Actual result:
--------------
a black 50x50 png image

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-01-01 21:15 UTC] jani@php.net
-Package: Feature/Change Request +Package: GD related
 [2011-02-04 13:22 UTC] milton dot andrade at canalup dot tv
Hi,

Not sure this is a bug.

if you do :

$im = imagecreatetruecolor(50,50);
header ("Content-type: image/x-png");
imagesavealpha($im, true);
$bg=imagecolorallocatealpha ($im, 0,0,0,127);
imagefill($im,0,0,$bg);
imagepng($im);
imagedestroy($im);

the result is what you want.
 [2011-02-04 13:31 UTC] pajoye@php.net
-Status: Open +Status: Bogus
 [2011-02-04 13:31 UTC] pajoye@php.net
imagealphablending is what you need too

no bug here.
 [2011-02-05 03:15 UTC] michel at breggen dot nl
holy crap, 7 years after reporting this bug, 20 versions of php and gd further somebody reports this as bogus??? really you must be kidding.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 25 22:01:29 2024 UTC