0

Hi all
i am having a small problem with my dynamic output code to produce a signature in php
the signature comes out fine with text but when i add another .png image to add ontop of the main signature i get a black background when i would like it transpearent to show like a users avatar.

my current code to output the signature:

header('Content-Type: image/png');  
    $im = @imagecreatefrompng('sigs/1.png') or die("Cannot select the correct image. Please contact the webmaster."); 
    $text_color = imagecolorallocate($im, 197,197,199); 
	$text_color_red = imagecolorallocate($im, 247,34,6);
    $text_username = "$username";
	$text_mypoints = "Points: ".numberFormat($mypoints)."";
	$text_mypoints1 = usersmypoints($id);
	$text_membertitle = "Member:";
	$text_totalposts = "Total Posts:";
	$text_totalposts_value = totalposts($id);
	$text_url = "http://";
	$outer = "../images/ranks/$tmp.png";
	$src = @imagecreatefrompng($outer);
    $font = 'sigs/arial.ttf'; 
	imagettftext($im, 8, 0, 171, 30, $text_color, $font, $text_membertitle); 
    imagettftext($im, 12, 0, 216, 30, $text_color, $font, $text_username); 
	imagettftext($im, 8, 0, 160, 47, $text_color, $font, $text_totalposts);
	imagettftext($im, 12, 0, 216, 47, $text_color, $font, $text_totalposts_value); 
	imagettftext($im, 7, 0, 15, 72, $text_color, $font, $text_url);   
    imagettftext($im, 10, 0, 10, 95, $text_color_red, $font, $text_mypoints); 
	imagettftext($im, 10, 0, 320, 95, $text_color, $font, $text_mypoints1);
	imagecopymerge($im, $src, 287, 20, 0, 0, 75, 71, 100);
	
    imagepng($im); 
    imagedestroy($im);

the below is the inner image on top of the main generated image

$outer = "../images/ranks/$tmp.png";
	$src = @imagecreatefrompng($outer);

i would like this to show in transparency

thankz

Edited by dualzNZ: n/a

2
Contributors
4
Replies
7
Views
5 Years
Discussion Span
Last Post by cereal
0

thanks for your reply
but this did not work it still shows a black background on the png image
i have changed the $png into $im being the refrence of the signature.

supplied screenshot of problem
screenshot of issue

Edited by dualzNZ: n/a

1

fixed thanks for your input i had to do the following

$outer = "../images/ranks/1.png";
	$src = imagecreatefrompng($outer);
	imagesavealpha($src, true);
	imagealphablending($src, true);

then to display it

imagecopy($im, $src, 0, 0, 0, 0, 75, 71);

instead of

imagecopymerge($im, $src, 287, 20, 0, 0, 75, 71, 100);
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.