首先了解这三个php图片处理函数的作用及用法
1、imagecreatefromstring() -- 从字符串中的图像流新建一图像
说明 : resource imagecreatefromstring ( string image )
imagecreatefromstring() 返回一个图像标识符,其表达了从给定字符串得来的图像。图像格式将自动检测,只要 PHP 支持:JPEG,PNG,GIF,WBMP 和 GD2。
返回值: 成功则返回图像资源,如果图像格式不支持,数据不是认可的格式,或者图像已损坏则返回 FALSE。
示例:
imagecreatefromstring(file_get_contents('./img.jpg')); //从当前目录下img.jpg为准新建一图像
2、imagecolorallocate() int imagecolorallocate(resource red,int blue) //为一幅图分配颜色
示例:
$white = imagecolorallocate($im,255,255,255);//返回由十进制整数设置为白色的标识符 $black = imagecolorallocate($im,0,0,0);//返回由十进制参数设置为黑色的标识符
3、imagettftext()
说明:array imagettftext ( resource size , float x , int color , string text )
参数:
image 由图象创建函数(例如imagecreatetruecolor())返回的图象资源。
size 字体的尺寸。根据 GD 的版本,为像素尺寸(GD1)或点(磅)尺寸(GD2)。
angle 角度制表示的角度,0 度为从左向右读的文本。更高数值表示逆时针旋转。例如 90 度表示从下向上读的文本。
x 由