function gd_info() { if (function_exists('gd_info')) { // built into PHP v4.3.0+ (with bundled GD2 library) return gd_info(); } static $gd_info = array(); if (empty($gd_info)) { // based on code by johnschaefer at gmx dot de // from PHP help on gd_info() $gd_info = array('GD Version' => '', 'FreeType Support' => false, 'FreeType Linkage' => '', 'T1Lib Support' => false, 'GIF Read Support' => false, 'GIF Create Support' => false, 'JPG Support' => false, 'PNG Support' => false, 'WBMP Support' => false, 'XBM Support' => false); $phpinfo_array = phpthumb_functions::phpinfo_array(); foreach ($phpinfo_array as $line) { $line = trim(strip_tags($line)); foreach ($gd_info as $key => $value) { //if (strpos($line, $key) !== false) { if (strpos($line, $key) === 0) { $newvalue = trim(str_replace($key, '', $line)); $gd_info[$key] = $newvalue; } } } if (empty($gd_info['GD Version'])) { // probable cause: "phpinfo() disabled for security reasons" if (function_exists('ImageTypes')) { $imagetypes = ImageTypes(); if ($imagetypes & IMG_PNG) { $gd_info['PNG Support'] = true; } if ($imagetypes & IMG_GIF) { $gd_info['GIF Create Support'] = true; } if ($imagetypes & IMG_JPG) { $gd_info['JPG Support'] = true; } if ($imagetypes & IMG_WBMP) { $gd_info['WBMP Support'] = true; } } // to determine capability of GIF creation, try to use ImageCreateFromGIF on a 1px GIF if (function_exists('ImageCreateFromGIF')) { if ($tempfilename = phpthumb::phpthumb_tempnam()) { if ($fp_tempfile = @fopen($tempfilename, 'wb')) { fwrite($fp_tempfile, base64_decode('R0lGODlhAQABAIAAAH//AP///ywAAAAAAQABAAACAUQAOw==')); // very simple 1px GIF file base64-encoded as string fclose($fp_tempfile); // if we can convert the GIF file to a GD image then GIF create support must be enabled, otherwise it's not $gd_info['GIF Read Support'] = (bool) @ImageCreateFromGIF($tempfilename); } unlink($tempfilename); } } if (function_exists('ImageCreateTrueColor') && @ImageCreateTrueColor(1, 1)) { $gd_info['GD Version'] = '2.0.1 or higher (assumed)'; } elseif (function_exists('ImageCreate') && @ImageCreate(1, 1)) { $gd_info['GD Version'] = '1.6.0 or higher (assumed)'; } } } return $gd_info; }