登 录
for($i = 0; $i < 4; $i++){ $rand .= dechex(rand(1, 15)); //dechex将10进制转为16进制 } $img = imagecreatetruecolor(60, 20); //创建图片 $bgcolor = imagecolorallocate($img, 180, 221, 247); //创建图片背景颜色 imagefill($img,0,0,$bgcolor); //添加随机线条 for($i = 0; $i < rand(0, 5); $i++){ $linecolor = imagecolorallocate($img, rand(0, 255), rand(0, 255), rand(0, 255)); imageline($img, rand(0, 60), rand(0, 20), rand(0, 60), rand(0, 20), $linecolor); } //添加随机噪点 for($i = 0; $i < rand(0, 200); $i++){ $pixelcolor = imagecolorallocate($img, rand(0, 255), rand(0, 255), rand(0, 255)); imagesetpixel($img, rand(0, 60), rand(0, 20), $pixelcolor); } $color = imagecolorallocate($img, 255, 255, 255); //文字颜色 imagestring($img, 6, 10, 3, $rand, $color); //向图片写入文字 header('content-type:image/png'); imagepng($img);
抱歉!评论已关闭.