Test gd support on server

Author: Mattias (mattias@999tutorials.com)
Categories: PHP
 GD is a package for manipulating images with PHP. Often it is installed, but not always. This script shows you all possible information about your GD configuration.
The tutorial:

Digg this, Post to del.icio.us,

If you have manipulated images through PHP you have probably ran over the package GD. GD is a package that can be used through PHP if it's compiled with GD-support. Depending on what version of PHP you have, you might have different support for functions in GD. (GD can be read about here: http://www.boutell.com/gd/).

I have created a great function that you can use to see both IF you have support for GD on your server, and also what functions are enabled. Some versions don't have support for all image formats (gif, png, jpg etc) because of copyright problems I think. Sometimes you have TTF (True type format) support so you can use fonts via gd when manipulating images.

Run this function which is pretty straight forward to see what the status is for your GD :-)

function showGDinformation()
{
echo "GD support on your server: ";

// Check if the function gd_info exists (great way to know if gd is istalled)
if(function_exists("gd_info"))
{
echo "YES";
$gd = gd_info();

// Show status of all values that might be supported(unsupported)
foreach($gd as $key => $value)
{
echo "
" . $key . ": ";
if($value)
echo "YES";
else
echo "NO";
}
}
else
echo "NO";
}

Basicly it checks if we have GD support by checking if the function gd_info() exist. It only does if you have the package. You will get a simple YES or NO in the output if you have support or not.

If you have support we get all gd-information via the function gd_info() and walk through it with foreach. Basicly I show all config values and after the name I show YES or NO.

This is the output I got on one of my servers:

GD support on your server: YES
GD Version: YES
FreeType Support: YES
FreeType Linkage: YES
T1Lib Support: NO
GIF Read Support: YES
GIF Create Support: YES
JPG Support: YES
PNG Support: YES
WBMP Support: YES
XBM Support: YES
JIS-mapped Japanese Font Support: NO

It looks like I can't write with Japanese fonts... Sounds ok with me, I don't understand what they say anyway :-)

Let me know if you need any help on how to get started with GD!!

Share this tutorial
 


Digg this, Post to del.icio.us,
 


eXTReMe Tracker