Jump to content

trasparent background for captcha


asmith

Recommended Posts

He guys

 

with a simple code i'm creating some captcha :

 

header("Content-Type: image/png"); 	// or image/jpg
// create the image resource

$image = ImageCreatefromgif("background.gif");

then at  last puting characters in the image : 

imagettftext($image, 30, angle, width, height, color, font, character);

 

i've tried using a transparent gif image for that , but the output background was black.

 

is there any way i could make a trasparent background for it?

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/108009-trasparent-background-for-captcha/
Share on other sites

<?php

$png = imagecreatetruecolor(800, 600);
imagesavealpha($png, true);

$trans_colour = imagecolorallocatealpha($png, 0, 0, 0, 127);
imagefill($png, 0, 0, $trans_colour);
   
$red = imagecolorallocate($png, 255, 0, 0);
imagettftext($png, 30, angle, width, height, $red, font, character);
   
header("Content-type: image/png");
imagepng($png);

?>

 

That *should* work. :S

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.