benslayton
06-26-2007, 03:48 AM
How do I make the Background transparent in this:
<?php
// Set the content-type
header("Content-type: image/png");
//Font Type
$fontType = $_GET["font"];
$fontFolder = "fonts/";
$fontEXT = ".ttf";
$font = $fontFolder . $fontType . $fontEXT;
//Font Size
$fontSize = $_GET["fsize"];
// Create the image
$im = imagecreatetruecolor(400, 30);
// Create some colors
$white = imagecolorallocate($im, 255, 255, 255);
$black = imagecolorallocate($im, 0, 0, 0);
$grey = imagecolorallocate($im, 128, 128, 128);
$red = imagecolorallocate($im, 255, 0, 0);
$blue = imagecolorallocate($im, 0, 0, 255);
$green = imagecolorallocate($im, 0, 255, 0);
$yellow = imagecolorallocate($im, 255, 255, 0);
$orange = imagecolorallocate($im, 255, 165, 0);
$pink = imagecolorallocate($im, 255, 0, 255);
//create background
imagefilledrectangle($im, 0, 0, 399, 29, $blue);
// The text to draw
$text = $_GET["text"];
// Add some shadow to the text
imagettftext($im, $fontSize, 0, 0, $fontSize, $black, $font, $text);
// Add the text
//imagettftext($im, $fontSize, 0, 10, 20, $white, $font, $text);
// Using imagepng() results in clearer text compared with imagejpeg()
imagepng($im);
imagedestroy($im);
?>
I am not quite sure how to do it.
<?php
// Set the content-type
header("Content-type: image/png");
//Font Type
$fontType = $_GET["font"];
$fontFolder = "fonts/";
$fontEXT = ".ttf";
$font = $fontFolder . $fontType . $fontEXT;
//Font Size
$fontSize = $_GET["fsize"];
// Create the image
$im = imagecreatetruecolor(400, 30);
// Create some colors
$white = imagecolorallocate($im, 255, 255, 255);
$black = imagecolorallocate($im, 0, 0, 0);
$grey = imagecolorallocate($im, 128, 128, 128);
$red = imagecolorallocate($im, 255, 0, 0);
$blue = imagecolorallocate($im, 0, 0, 255);
$green = imagecolorallocate($im, 0, 255, 0);
$yellow = imagecolorallocate($im, 255, 255, 0);
$orange = imagecolorallocate($im, 255, 165, 0);
$pink = imagecolorallocate($im, 255, 0, 255);
//create background
imagefilledrectangle($im, 0, 0, 399, 29, $blue);
// The text to draw
$text = $_GET["text"];
// Add some shadow to the text
imagettftext($im, $fontSize, 0, 0, $fontSize, $black, $font, $text);
// Add the text
//imagettftext($im, $fontSize, 0, 10, 20, $white, $font, $text);
// Using imagepng() results in clearer text compared with imagejpeg()
imagepng($im);
imagedestroy($im);
?>
I am not quite sure how to do it.