Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- How to create an image with transparent background
- header('content-type: image/png');
- $image = imagecreatetruecolor(900, 350);
- imagealphablending($image, true);
- imagesavealpha($image, true);
- $text_color = imagecolorallocate($image, 0, 51, 102);
- imagestring($image,2,4,4,'Test',$text_color);
- imagepng($image);
- imagedestroy($image);
- imagefill($image,0,0,0x7fff0000);
- alpha = 0x7f
- red = 0xff
- green = 0x00
- blue = 0x00
- $im = @imagecreatetruecolor(100, 25);
- # important part one
- imagesavealpha($im, true);
- imagealphablending($im, false);
- # important part two
- $white = imagecolorallocatealpha($im, 255, 255, 255, 127);
- imagefill($im, 0, 0, $white);
- # do whatever you want with transparent image
- $lime = imagecolorallocate($im, 204, 255, 51);
- imagettftext($im, $font, 0, 0, $font - 3, $lime, "captcha.ttf", $string);
- header("Content-type: image/png");
- imagepng($im);
- imagedestroy($im);
Add Comment
Please, Sign In to add comment