<?php
header('Content-type:image/jpeg');
$width=120;
$height=40;
$element=array('a','b','c','d','e','f','s');
$string='';
for ($i=0;$i<3;$i++){
$string.=$element[rand(0,count($element)-1)];
}
$img = imagecreatetruecolor($width, $height);
//将背景设置为白色的
$colorBg=imagecolorallocate($img,rand(200,255),rand(200,255),rand(200,255));
$colorBorder=imagecolorallocate($img,rand(200,255),rand(200,255),rand(200,255));
$colorString=imagecolorallocate($img,rand(10,100),rand(10,100),rand(10,100));
//将白色铺满地图
imagefill($img, 0, 0, $colorBg);
imagerectangle($img,0,0,$width-1,$height-1,$colorBorder);
for ($i=0;$i<100;$i++){
imagesetpixel($img,rand(0,$width-1),rand(0,$height-1),imagecolorallocate($img,rand(100,200),rand(100,200),rand(100,200)));
}
for ($i=0;$i<4;$i++){
imageline($img,rand(0,$width/2),rand(0,$height),rand($width/2,$width),rand(0,$height/2),imagecolorallocate($img,rand(100,200),rand(100,200),rand(100,200)));
}
imagettftext($img,24,10,rand(0,$width/2),rand(30,$height/3),$colorString,'D:\phpstudy_pro\WWW\aj\font\QianTuMaKeShouXieTi-2.ttf',$string);
imagejpeg($img);
|