Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with making images using GD

Status
Not open for further replies.

748323

Programmer
Dec 10, 2004
70
US
This is supposed to randomly choose 3 letters, and place them in an image. All it does right now is choose a random background color, which is not what I want. The background is supposed to be white, anyways. Any idea why this doesn't work? Thanks.

Code:
<?

$picture = imagecreate(200,200);
$lets = "abcdefghijklmnopqrstuvwxyz123456789";
$string = $lets{rand(0,34)} . $lets{rand(0,34)} . $lets{rand(0,34)};
$font_size = 20;
$font_color = imagecolorallocate($picture, rand(60,100), rand(60,100), rand(60,100));
$background_color = imagecolorallocate ($picture, 255, 255, 255);
$x = rand(40,80);
$y = rand(40,80);
$rotation = rand(-45, 45);

$file = "1.TTF";
imagettftext ($picture, $font_size, $rotation, $x, $y, $font_color, $file, $string);

header ("Content-type: image/png");
imagepng ($picture);

?>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top