PHP Developers Network

A community of PHP developers offering assistance, advice, discussion, and friendship.
 
Loading
It is currently Thu Nov 15, 2018 2:16 am

All times are UTC - 5 hours




Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: Wed Feb 25, 2009 3:23 pm 
Offline
Forum Newbie

Joined: Sun Dec 07, 2008 9:54 pm
Posts: 21
does anyone know why i get a black background when generating png images in the following code:

Syntax: [ Download ] [ Hide ]
 
//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);
 


Top
 Profile  
 
PostPosted: Wed Feb 25, 2009 4:06 pm 
Offline
Jedi Mod
User avatar

Joined: Tue Dec 21, 2004 6:03 pm
Posts: 5263
Location: usrlab.com
Because imagesavealpha() is set to false.


Top
 Profile  
 
PostPosted: Wed Feb 25, 2009 4:34 pm 
Offline
Forum Newbie

Joined: Sun Dec 07, 2008 9:54 pm
Posts: 21
thanks, that did it


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group