[ Team LiB ] Previous Section Next Section

Checking Your Configuration with gd_info()

Although the GD library is bundled with PHP, some features (such as JPEG support, for example) require external libraries. You can see which features PHP is compiled to support with the gd_info() function. gd_info() requires no arguments and returns an associative array describing your GD setup. Table 15.1 lists the elements of the array returned by gd_info().

Table 15.1. The Array Returned by gd_info()

Element

Description

GD Version

The version of GD used; bundled (2.0.15 compatible), for example

FreeType Support

Whether FreeType fonts are supported (0 or 1)

FreeType Linkage

The library used to provide FreeType functionality; with TTF library, for example.

T1Lib Support

Support for Type 1 fonts

GIF Read Support

Read-only support for the GIF format (0 or 1)

GIF Create Support

Support for creating and manipulating GIF data (0 or 1)

JPG Support

Support for reading, creating, and manipulating JPEG data (0 or 1)

PNG Support

Support for reading, creating, and manipulating PNG data (0 or 1)

WBMP Support

Support for reading, creating, and manipulating wireless bitmap data (0 or 1)

XPM Support

Support for reading, creating, and manipulating X Windows pixmap image data (0 or 1)

XBM Support

Support for reading, creating, and manipulating X Windows bitmap image data (0 or 1)

JIS-mapped Japanese Font Support

Support for Japanese International Standard character set (0 or 1)

We can run gd_info() in a script like so:


print "<pre>";
print_r( gd_info() );
print "</pre>";

Notice that we output the array using print_r() and maintain formatting by wrapping our output in a <pre> element. On our system the output looks like this:


Array
(
  [GD Version] => bundled (2.0.15 compatible)
  [FreeType Support] => 1
  [FreeType Linkage] => with TTF library
  [T1Lib Support] =>
  [GIF Read Support] => 1
  [GIF Create Support] =>
  [JPG Support] => 1
  [PNG Support] => 1
  [WBMP Support] => 1
  [XPM Support] =>
  [XBM Support] => 1
  [JIS-mapped Japanese Font Support] =>
)

We can see from this output that it would be a mistake to attempt to output a GIF file, but we can work with the JPEG and PNG formats.

    [ Team LiB ] Previous Section Next Section