Home > Backend Development > PHP Tutorial > 怎么改变php验证码字体的大小

怎么改变php验证码字体的大小

WBOY
Release: 2016-06-13 12:16:47
Original
3082 people have browsed it

如何改变php验证码字体的大小



[color=#0000FF]这个验证码图片里面显示的数字太小了 ,如何在下面的代码改一下字体的的大小,是数字变得大一些[/color]
//生成验证码图片
Header("Content-type: image/PNG");
$rand ="";
for($i=0;$i$rand.=dechex(rand(0,15));
}

$im = imagecreate(100,50); //制定图片背景大小

$black = ImageColorAllocate($im, 0,0,0); //设定三种颜色
$white = ImageColorAllocate($im, 255,255,255);
$gray = ImageColorAllocate($im, 200,200,200);
for($i=0;$i$te=imagecolorallocate($im,rand(0,255),rand(0,255),rand(0,255));
}
imagefill($im,0,0,$gray); //采用区域填充法,设定(0,0)

while(($rand=rand()%100000)//将四位整数验证码绘入图片
$_SESSION['rand']=$rand;
imagestring($im, 5, 30, 20, $rand, $te);
// 用 col 颜色将字符串 s 画到 image 所代表的图像的 x,y 座标处(图像的左上角为 0, 0)。
//如果 font 是 1,2,3,4 或 5,则使用内置字体

for($i=0;$i{
$randcolor = ImageColorallocate($im,rand(0,255),rand(0,255),rand(0,255));
imagesetpixel($im, rand()%100 , rand()%50 , $randcolor);
}
imageline($im,0,rand(0,100),100,rand(0,15),$randcolor);
imageline($im,0,rand(0,100),100,rand(0,15),$randcolor);
imageline($im,0,rand(0,100),100,rand(0,15),$randcolor);
ImagePNG($im);
ImageDestroy($im);

?>

------解决思路----------------------
imagestring($im, 5, 30, 20, $rand, $te);这个函数使用的是内置字体,范围是1-5。只能换成imagettftext()函数。

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template