$image = imagecreatetruecolor(100, 30); // 创建一个宽为 100 高为 30 的底图 该底图的背景色 为黑色 是系统定义的 $bgcolor = imagecolorallocate($image, 255, 255, 255); // 为上面创建的底图分配 白色的背景颜色 imagefill($image, 0, 0, $bgcolor); // 填充白色背景色
// 输出验证码内容
for ($i=0; $i < 4; $i++) {
$fontsize = 6;
$fontcolor = imagecolorallocate($image, rand(0,120), rand(0,120), rand(0,120));
$data = 'qwertyuipkjhgfdsazxcvbnm23456789';
$content = substr($data, rand(0, strlen($data)), 1);
$x = ($i*100/4) + rand(5,9);
$y = rand(5,10);
imagestring($image, $fontsize, $x, $y, $content, $fontcolor); //在图像上水平输出一行字符串
}
// 增加干扰点元素
for ($i=0; $i < 300; $i++) {
$pointcolor = imagecolorallocate($image, rand(50,200), rand(50,200), rand(50,200));
imagesetpixel($image, rand(0,99), rand(0,29), $pointcolor);
} //开源软件:phpfensi.com
// 增加干扰线元素 线 和 点 的颜色一定要控制好 要比验证码数字的颜色浅 避免出现验证码数字看不见的现象
for ($i=0; $i < 4; $i++) {
$linecolor = imagecolorallocate($image, rand(100,240), rand(100,240), rand(100,240));
imageline($image, rand(0,99), rand(0,29), rand(0,99), rand(0,29), $linecolor);
}
// 输出创建的图像 在输出图像之前 必须输出头信息 用来规定输出的图像类型
header("Content-Type: image/png");
imagepng($image);
// 销毁图像
imagedestroy($image);
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有