<?php
header("Content-Type:text/html;Charset=UTF-8");// 设置页面的编码风格
header("Content-Type:image/jpeg");// 通知浏览器输出的是jpeg格式的图像
$img = imagecreatetruecolor(150,50);//创建画布并设置大小 x轴150 y轴50
$bgcolor = imagecolorallocate($img, mt_rand(0,255), mt_rand(0,255), mt_rand(0,255));//分配背景颜色
imagefill($img, 0, 0, $bgcolor); ////把背景填充到图像
imagejpeg($img); // 输出图像
imagedestroy($img); // 销毁图像
?>
resource imagecreatetruecolor ( int $width , int $height )
resource imagecreate ( int $x_size , int $y_size )
int imagecolorallocate ( resource $image , int $red , int $green , int $blue )
int mt_rand ( int $min , int $max )
<?php
header("Content-Type:text/html;Charset=UTF-8");// 设置页面的编码风格
header("Content-Type:image/jpeg");// 通知浏览器输出的是jpeg格式的图像
$img = imagecreatetruecolor(150,50);//创建画布并设置大小 x轴150 y轴50
$bgcolor = imagecolorallocate($img, mt_rand(0,255), mt_rand(0,255), mt_rand(0,255));//分配背景颜色
//添加干扰线,并循环3次,背景颜色随机
for($i=0;$i<3;$i++){
$linecolor = imagecolorallocate($img,mt_rand(0,255),mt_rand(0,255),mt_rand(0,255));
imageline($img, mt_rand(0,150), mt_rand(0,50), mt_rand(0,150), mt_rand(0,50), $linecolor);
}
//添加干扰点,并循环25次,背景颜色随机
for($i=0;$i<25;$i++){
$dotcolor = imagecolorallocate($img, mt_rand(0,255), mt_rand(0,255), mt_rand(0,255));
imagesetpixel($img, mt_rand(0,150), mt_rand(0,60), $dotcolor);
}
imagefill($img, 0, 0, $bgcolor); ////把背景填充到图像
imagejpeg($img); // 输出图像
imagedestroy($img); // 销毁图像
?>
<?php
header("Content-Type:text/html;Charset=UTF-8");// 设置页面的编码风格
header("Content-Type:image/jpeg");// 通知浏览器输出的是jpeg格式的图像
$img = imagecreatetruecolor(150,50);//创建画布并设置大小 x轴150 y轴50
$bgcolor = imagecolorallocate($img, mt_rand(0,255), mt_rand(0,255), mt_rand(0,255));//分配背景颜色
//添加干扰线,并循环3次,背景颜色随机
for($i=0;$i<3;$i++){
$linecolor = imagecolorallocate($img,mt_rand(0,255),mt_rand(0,255),mt_rand(0,255));
imageline($img, mt_rand(0,150), mt_rand(0,50), mt_rand(0,150), mt_rand(0,50), $linecolor);
}
//添加干扰点,并循环25次,背景颜色随机
for($i=0;$i<25;$i++){
$dotcolor = imagecolorallocate($img, mt_rand(0,255), mt_rand(0,255), mt_rand(0,255));
imagesetpixel($img, mt_rand(0,150), mt_rand(0,60), $dotcolor);
}
//添加需要验证的字母或者数字
$rand_str = "qwertyuiopasdfghjklzxcvbnm1234567890";//需要使用到验证的一些字母和数字
$str_arr = array(); //命名一个数组
for($i = 0;$i<4;$i++){ //循环4次,就是有四个随机的字母或者数字
$pos = mt_rand(0,strlen($rand_str)-1);
$str_arr[] = $rand_str[$pos];//临时交换
}
$x_start=150/4;//单个字符X轴位置
foreach ($str_arr as $key) {
$fontcolor = imagecolorallocate($img, mt_rand(0,255), mt_rand(0,255), mt_rand(0,255));
imagettftext($img, 25, mt_rand(-15,15), $x_start, 50/2, $fontcolor, "C:/Windows/Fonts/Verdana.TTF", $key);
$x_start +=20;//遍历后单个字符沿X轴 +20
}
imagefill($img, 0, 0, $bgcolor); ////把背景填充到图像
imagejpeg($img); // 输出图像
imagedestroy($img); // 销毁图像
?>
array imagettftext ( resource $image , float $size , float $angle , int $x , int $y , int $color , string $fontfile , string $text )
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有