php gd库的细节


今天早晨听到imagerotate()函数不能用,一查是gd库里面的东西。

phpinfo里面显示都正常,显示如下:

gd
GD Support => enabled
GD Version => 2.0 or higher
FreeType Support => enabled
FreeType Linkage => with freetype
FreeType Version => 2.2.1
GIF Read Support => enabled
GIF Create Support => enabled
JPG Support => enabled
PNG Support => enabled
WBMP Support => enabled

使用 var_dump (get_extension_funcs(“gd”)); 检查,确实没有这个函数

看看官方网站的说明吧:

http://cn2.php.net/manual/en/function.imagerotate.php

Note: This function is only available if PHP is compiled with the bundled version of the GD library.

bundled version 就是php自带的GD库,因为当时是自己装的GD库,所以出现问题

以前编译参数:… –with-gd=/www/gd2 …

重新编译 ./configure … –with-gd … (这样就会使用它自己带的GD库)

安装完成,phpinfo

gd
GD Support => enabled
GD Version => bundled (2.0.34 compatible)
FreeType Support => enabled
FreeType Linkage => with freetype
FreeType Version => 2.2.1
GIF Read Support => enabled
GIF Create Support => enabled
JPG Support => enabled
PNG Support => enabled
WBMP Support => enabled
XBM Support => enabled

明白了吧。这样就支持imagerotate函数了,还多了几个其他的函数。

imagefilter …

  1. #1 by edy.liu on 2009-01-15 - 14:51

    JPEG需要外加的库才能正常使用
    JPEG support is only available if PHP was compiled against GD-1.8 or later.
    http://freshmeat.net/projects/libjpeg/

(will not be published)