DAY60

学前了解:
在PHP中可以通过GD库处理图像
创建一个图像应该完成如下所示的四个基本步骤:
1.创建图像
2.绘制图像
3.输出图像
header函数注意点
在该函数之前,不能输出任何内容

在我们的PHP代码 的函数里面,我们使用的/开头的路径 这个/不是指 web根目录,而是操作系统的 文件的根目录!

4.释放资源


设计验证码的步骤:

水印

<?php
header('Content-type:image/jpeg');
$img=imagecreatefromjpeg('images/zcx.jpg');
$color=imagecolorallocate($img,255,255,255);

$width=imagesx($img);//取得图像宽度
$height=imagesy($img);//取得图像高度
$position=imagettfbbox(20,0,'font/china1.TTF','小刚/周传雄');
//取得使用 TrueType 字体的文本的范围
$stringWidth=$position[2]-$position[0];

imagettftext($img,20,0,$width-1-$stringWidth-($width/30),$height-1-($height/30), $color,'font/china1.TTF','小刚/周传雄');
imagejpeg($img);//输出图象到浏览器或文件。
imagedestroy($img);

 

原文地址:https://www.cnblogs.com/qianjilou/p/6939911.html