Page 1 of 1

getting black background w/ imagepng

Posted: Wed Feb 25, 2009 2:23 pm
by fairyprincess18
does anyone know why i get a black background when generating png images in the following code:

Code: Select all

 
//create image from existing png file
$im = imagecreatefrompng("overlay.png");
 
//transparent background and black text
//$bg = imagecolorallocate($im, 0, 0, 0);
//$bg = imagecolortransparent($im,$bg);
$textcolor = imagecolorallocate($im, 0, 0 , 0);
 
$divNum = 0;
 
$divNum = $bandwidth / 1000;
$gigNum = $divNum . "Gb";
 
//convert strings into images
imagestring($im, 5, 32, 20, $gigNum, $textcolor);
 
//directory in which to save generated images
$savePath = 'images/' . $gigNum . '.png';
 
//output images to files
header('Content-type: image/png');
imagepng($im, $savePath);
imagedestroy($im);
 

Re: getting black background w/ imagepng

Posted: Wed Feb 25, 2009 3:06 pm
by onion2k
Because imagesavealpha() is set to false.

Re: getting black background w/ imagepng

Posted: Wed Feb 25, 2009 3:34 pm
by fairyprincess18
thanks, that did it