Copy CodeThe code is as follows:
File Header ...
Header ("Content-type:image/png");
Create True Color white paper
$im = @imagecreatetruecolor (a) or Die ("Build image Failed");
Get background color
$background _color = imagecolorallocate ($im, 255, 255, 255);
Fill the background color (this thing is like oil barrels)
Imagefill ($im, 0,0, $background _color);
Get border color
$border _color = imagecolorallocate ($im, 200,200,200);
Draw a rectangle, border color 200,200,200
Imagerectangle ($im, 0,0,49,19, $border _color);
Line up background, full screen with 1 or 0
for ($i =2; $i <18; $i + +) {
Get random tint
$line _color = Imagecolorallocate ($im, Rand (200,255), Rand (200,255), Rand (200,255));
Draw Line
Imageline ($im, 2, $i, $i, $line _color);
}
Set Font size
$font _size=12;
Set up the printed text
$Str [0] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
$STR [1] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
$STR [2] = "01234567891234567890123456";
Get a 1th random text
$imstr [0]["s"] = $Str [rand (0,2)][rand (0,25)];
$IMSTR [0]["x"] = rand (2,5);
$imstr [0]["y"] = rand (1,4);
Get a 2nd random text
$imstr [1]["s"] = $Str [rand (0,2)][rand (0,25)];
$IMSTR [1]["x"] = $imstr [0]["x"]+ $font _size-1+rand (0,1);
$imstr [1]["y"] = rand (1,3);
Get a 3rd random text
$imstr [2]["s"] = $Str [rand (0,2)][rand (0,25)];
$IMSTR [2]["x"] = $imstr [1]["x"]+ $font _size-1+rand (0,1);
$imstr [2]["y"] = rand (1,4);
Get a 4th random text
$imstr [3]["s"] = $Str [rand (0,2)][rand (0,25)];
$IMSTR [3]["x"] = $imstr [2]["x"]+ $font _size-1+rand (0,1);
$imstr [3]["y"] = rand (1,3);
Write Random string
for ($i =0; $i <4; $i + +) {
Get a random darker color
$text _color = Imagecolorallocate ($im, Rand (50,180), Rand (50,180), Rand (50,180));
Drawing text
Imagechar ($im, $font _size, $imstr [$i] ["X"], $imstr [$i] ["Y"], $imstr [$i] ["s"], $text _color);
}
Show pictures
Imagepng ($im);
Destroying pictures
Imagedestroy ($im);
?>
http://www.bkjia.com/PHPjc/318807.html www.bkjia.com true http://www.bkjia.com/PHPjc/318807.html techarticle Copy the code as follows:? PHP//File header ("Content-type:image/png");//create True Color white Paper $im = @imagecreatetruecolor (50,20) Ordie (" Build image Failed "); Get the background beauty ...