GD库提供了一系列用来处理图片的API,使用GD库可以处理图片,或者生成图片。
在网站上GD库通常用来生成缩略图或者用来对图片加水印或者对网站数据生成报表。
通过php.ini 启用GD库
;extension=php_gd2.dll
取消最前边的;号即可启动
GD库中简单的图片操作函数
1、 imagecreatetruecolor 新建一个真彩色图像
imagecreatetruecolor ( int x_size, int y_size ) // x就是宽 ,y就是高
2、imagecolorallocate 为一幅图像分配颜色
imagecolorallocate ( resource image, int red, int green, int blue )
第一次调用为图像设置背景色,第二次获得颜色编码
3、imagestring 绘图函数
imagestring ( resource image, font, int x, int y, 内容 , 颜色 )
font为1-6