]> granicus.if.org Git - php/commitdiff
new function gd_info() returns an associative array of gd support options. # The...
authorMarcus Boerger <helly@php.net>
Tue, 12 Nov 2002 11:49:11 +0000 (11:49 +0000)
committerMarcus Boerger <helly@php.net>
Tue, 12 Nov 2002 11:49:11 +0000 (11:49 +0000)
# easy to look into phpinfo() to see which index names are possible.

ext/gd/gd.c
ext/gd/php_gd.h

index 3ec5e9ca96bed87d0f5865c96fcf17b918a79f90..6768a4d3e20443de99cb7d94ca6ba52e95102508 100644 (file)
@@ -117,6 +117,7 @@ static void _php_image_bw_convert(gdImagePtr im_org, gdIOCtx *out, int threshold
 /* {{{ gd_functions[]
  */
 function_entry gd_functions[] = {
+       PHP_FE(gd_info,                                 NULL)
        PHP_FE(imagearc,                                                                NULL)
        PHP_FE(imageellipse,                                                    NULL)
        PHP_FE(imagechar,                                                               NULL)
@@ -418,6 +419,82 @@ PHP_MINFO_FUNCTION(gd)
 }
 /* }}} */
 
+/* {{{ proto array gd_info()
+ */
+PHP_FUNCTION(gd_info)
+{
+       if (ZEND_NUM_ARGS()!=0) {
+               ZEND_WRONG_PARAM_COUNT();
+               RETURN_FALSE;
+       }
+
+       if (array_init(return_value) == FAILURE) {
+               php_error_docref(NULL TSRMLS_CC, E_ERROR, "Unable to initialize array");
+               RETURN_FALSE;
+       }
+#if HAVE_GD_BUNDLED
+       add_assoc_string(return_value, "GD Version", "bundled (2.0 compatible)", 1);
+#elif HAVE_LIBGD20
+       add_assoc_string(return_value, "GD Version", "2.0 or higher", 1);
+#elif HAVE_GDIMAGECOLORRESOLVE
+       add_assoc_string(return_value, "GD Version", "1.6.2 or higher", 1);
+#elif HAVE_LIBGD13
+       add_assoc_string(return_value, "GD Version", "between 1.3 and 1.6.1", 1);
+#else
+       add_assoc_string(return_value, "GD Version", "1.2", 1);
+#endif
+
+#ifdef ENABLE_GD_TTF
+       add_assoc_bool(return_value, "FreeType Support", 1);
+#if HAVE_LIBFREETYPE
+       add_assoc_string(return_value, "FreeType Linkage", "with freetype", 1);
+#elif HAVE_LIBTTF
+       add_assoc_string(return_value, "FreeType Linkage", "with TTF library", 1);
+#else
+       add_assoc_string(return_value, "FreeType Linkage", "with unknown library", 1);
+#endif
+#else
+       add_assoc_bool(return_value, "FreeType Support", 0);
+#endif
+
+#ifdef HAVE_LIBT1
+       add_assoc_bool(return_value, "T1Lib Support", 1);
+#else
+       add_assoc_bool(return_value, "T1Lib Support", 0);
+#endif
+#ifdef HAVE_GD_GIF_READ
+       add_assoc_bool(return_value, "GIF Read Support", 1);
+#else
+       add_assoc_bool(return_value, "GIF Read Support", 0);
+#endif
+#ifdef HAVE_GD_GIF_CREATE
+       add_assoc_bool(return_value, "GIF Create Support", 1);
+#else
+       add_assoc_bool(return_value, "GIF Create Support", 0);
+#endif
+#ifdef HAVE_GD_JPG
+       add_assoc_bool(return_value, "JPG Support", 1);
+#else
+       add_assoc_bool(return_value, "JPG Support", 0);
+#endif
+#ifdef HAVE_GD_PNG
+       add_assoc_bool(return_value, "PNG Support", 1);
+#else
+       add_assoc_bool(return_value, "PNG Support", 0);
+#endif
+#ifdef HAVE_GD_WBMP
+       add_assoc_bool(return_value, "WBMP Support", 1);
+#else
+       add_assoc_bool(return_value, "WBMP Support", 0);
+#endif
+#ifdef HAVE_GD_XBM
+       add_assoc_bool(return_value, "XBM Support", 1);
+#else
+       add_assoc_bool(return_value, "XBM Support", 0);
+#endif
+}
+/* }}} */
+
 /* Need this for cpdf. See also comment in file.c php3i_get_le_fp() */
 PHP_GD_API int phpi_get_le_gd(void)
 {
index 7b7bf341f15855d4cd09b58d2533d3b031b0f950..149f9092ba5a47f6b8116c4f3e2f54cc5112e1a9 100644 (file)
@@ -59,6 +59,7 @@ PHP_MINFO_FUNCTION(gd);
 PHP_MINIT_FUNCTION(gd);
 PHP_MSHUTDOWN_FUNCTION(gd);
 
+PHP_FUNCTION(gd_info);
 PHP_FUNCTION(imagearc);
 PHP_FUNCTION(imagechar);
 PHP_FUNCTION(imagecharup);