Home > php教程 > php手册 > body text

PHP利用GD库画图和生成验证码图片

WBOY
Release: 2016-06-13 09:11:24
Original
855 people have browsed it

PHP利用GD库画图和生成验证码图片

首先得确定php.ini设置有没有打开GD扩展功能,测试如下

 

print_r(gd_info());
Copy after login

如果有打印出内容如下,则说明GD功能有打开:

Array
(
    [GD Version] => bundled (2.0.34 compatible)
    [FreeType Support] => 1
    [FreeType Linkage] => with freetype
    [T1Lib Support] => 1
    [GIF Read Support] => 1
    [GIF Create Support] => 1
    [JPG Support] => 1
    [PNG Support] => 1
    [WBMP Support] => 1
    [XPM Support] => 
    [XBM Support] => 1
    [JIS-mapped Japanese Font Support] => 
)
Copy after login

GD画图一般步骤如下:

1.创建一张画布资源

2.创建颜色画笔

3.画图

4.保存图片或输出图片

5.销毁内存画布资源

测试代码如下:


Copy after login

测试图片如下:

注:GD库强大的可以画各种报表(如柱状图,饼状图等)、缩略图、加水印图和股票走势图


Copy after login


 

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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!