图片验证码
来源:互联网 发布:荒野行动知乎 编辑:程序博客网 时间:2024/06/05 11:42
<?php
header('Content-type: image/png');
/**
* Created by coder meng.
* User: coder meng
* Date: 2016/4/9 16:05
*/
// 1.创建画布
$width=100;
$height=30;
$im=imagecreatetruecolor($width,$height);
//2.设置颜色
$red=imagecolorallocate($im,255,0,0);
$green=imagecolorallocate($im,0,255,0);
$blue=imagecolorallocate($im,0,0,255);
$white=imagecolorallocate($im,192,220,192);
$color=imagecolorallocate($im,rand(0,255),rand(0,255),rand(0,255));
//3.填充颜色
imagefill($im,0,0,$white);
for($i=0;$i<100;$i++)
{
//画点
imagesetpixel($im,rand(0,$width),rand(0,$height),$color);
//画线
}
for($j=0;$j<10;$j++)
{
imageline($im,rand(0,$width),rand(0,$height),rand(0,$width),rand(0,$height),$color);
}
$text=rand(1000,9999);
// Replace path by your own font path
$font='consola.ttf';
// Add some shadow to the text
imagettftext($im,20,0,11,21,$color,$font,$text);
imagepng($im);
//5关闭资源
imagedestroy($im);
header('Content-type: image/png');
/**
* Created by coder meng.
* User: coder meng
* Date: 2016/4/9 16:05
*/
// 1.创建画布
$width=100;
$height=30;
$im=imagecreatetruecolor($width,$height);
//2.设置颜色
$red=imagecolorallocate($im,255,0,0);
$green=imagecolorallocate($im,0,255,0);
$blue=imagecolorallocate($im,0,0,255);
$white=imagecolorallocate($im,192,220,192);
$color=imagecolorallocate($im,rand(0,255),rand(0,255),rand(0,255));
//3.填充颜色
imagefill($im,0,0,$white);
for($i=0;$i<100;$i++)
{
//画点
imagesetpixel($im,rand(0,$width),rand(0,$height),$color);
//画线
}
for($j=0;$j<10;$j++)
{
imageline($im,rand(0,$width),rand(0,$height),rand(0,$width),rand(0,$height),$color);
}
$text=rand(1000,9999);
// Replace path by your own font path
$font='consola.ttf';
// Add some shadow to the text
imagettftext($im,20,0,11,21,$color,$font,$text);
imagepng($im);
//5关闭资源
imagedestroy($im);
0 0
- C#图片验证码
- 图片验证码
- 图片验证码
- 图片验证码
- 获取验证码图片
- jsp验证码图片
- PHP图片验证码
- 图片验证码
- 图片验证码
- 验证码图片显示
- 中文图片验证码
- 验证码图片生成
- jsp图片验证码
- 生成图片验证码
- 图片验证码
- 绘制验证码图片
- java图片验证码
- java图片验证码
- 签名来保证ASP.NET MVC OR WEBAPI的接口安全
- 知识竞赛时,竞赛活动主题及环节主题如何修改?
- Github Page - 搭建自己的个人页面
- classList API
- 一个老程序员这些年的心得体会
- 图片验证码
- nodeJS实现牛客网、赛码网在线编程输入输出
- Spring Security学习笔记之ChannelProcessingFilter
- Java反射机制在工厂模式中的应用
- 添加Linux普通用户
- android 国际化
- 14.3-6 MIN GAP
- UnicodeEncodeError: ‘gbk’ codec can’t encode character u’\u200e’ in position 43: illegal multibyte s
- react native 市场需要的技能