cvs: /php4/ext/gd gd.c gdt1.h php_gd.h
| From: | Hartmut Holzgraefe | Date: | Tue, 02 May 2000 14:10:51 +0000 |
| Subject: | cvs: /php4/ext/gd gd.c gdt1.h php_gd.h | ||
| Groups: | php.version4 | ||
| Request: | Send a blank email to php-version4+get-14357@lists.php.net to get a copy of this message | ||
hholzgra Tue May 2 07:10:51 2000 EDT
Modified files:
/php4/ext/gd gd.c gdt1.h php_gd.h
Log:
calling a function that is not supported in the current build due to a
missing library or unsupported feature (especially GIF-Output)
will now give a slightly more usefull error message than eg.
" Call to undefined function: imagegif()"
(this seemed to confuse a lot of users ....)
Index: php4/ext/gd/gd.c
diff -u php4/ext/gd/gd.c:1.56 php4/ext/gd/gd.c:1.57
--- php4/ext/gd/gd.c:1.56 Mon May 1 17:44:23 2000
+++ php4/ext/gd/gd.c Tue May 2 07:10:51 2000
@@ -18,7 +18,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: gd.c,v 1.56 2000/05/02 00:44:23 sas Exp $ */
+/* $Id: gd.c,v 1.57 2000/05/02 14:10:51 hholzgra Exp $ */
/* gd 1.2 is copyright 1994, 1995, Quest Protein Database Center,
Cold Spring Harbor Labs. */
@@ -111,18 +111,12 @@
PHP_FE(imagecopy, NULL)
PHP_FE(imagecopyresized, NULL)
PHP_FE(imagecreate, NULL)
-#ifdef HAVE_GD_PNG
PHP_FE(imagecreatefrompng, NULL)
PHP_FE(imagepng, NULL)
-#endif
-#ifdef HAVE_GD_GIF
PHP_FE(imagecreatefromgif, NULL)
PHP_FE(imagegif, NULL)
-#endif
-#ifdef HAVE_GD_JPG
PHP_FE(imagecreatefromjpeg, NULL)
PHP_FE(imagejpeg, NULL)
-#endif
PHP_FE(imagedestroy, NULL)
PHP_FE(imagefill, NULL)
PHP_FE(imagefilledpolygon, NULL)
@@ -141,11 +135,8 @@
PHP_FE(imagesx, NULL)
PHP_FE(imagesy, NULL)
PHP_FE(imagedashedline, NULL)
-#ifdef ENABLE_GD_TTF
PHP_FE(imagettfbbox, NULL)
PHP_FE(imagettftext, NULL)
-#endif
-#if HAVE_LIBT1
PHP_FE(imagepsloadfont, NULL)
/*
PHP_FE(imagepscopyfont, NULL)
@@ -156,7 +147,6 @@
PHP_FE(imagepsslantfont, NULL)
PHP_FE(imagepstext, NULL)
PHP_FE(imagepsbbox, NULL)
-#endif
{NULL, NULL, NULL}
};
@@ -425,12 +415,12 @@
}
/* }}} */
-#ifdef HAVE_GD_PNG
/* {{{ proto int imagecreatefrompng(string filename)
Create a new image from PNG file or URL */
PHP_FUNCTION(imagecreatefrompng)
{
+#ifdef HAVE_GD_PNG
zval **file;
gdImagePtr im;
char *fn=NULL;
@@ -463,6 +453,10 @@
RETURN_FALSE;
}
ZEND_REGISTER_RESOURCE(return_value, im, GDG(le_gd));
+#else /* HAVE_GD_PNG */
+ php_error(E_WARNING, "ImageCreateFromPng: No PNG support in this PHP build");
+ RETURN_FALSE;
+#endif /* HAVE_GD_PNG */
}
/* }}} */
@@ -470,6 +464,7 @@
Output PNG image to browser or file */
PHP_FUNCTION(imagepng)
{
+#ifdef HAVE_GD_PNG
zval **imgind, **file;
gdImagePtr im;
char *fn=NULL;
@@ -529,17 +524,19 @@
/* the temporary file is automatically deleted */
}
RETURN_TRUE;
+#else /* HAVE_GD_PNG */
+ php_error(E_WARNING, "ImagePng: No PNG support in this PHP build");
+ RETURN_FALSE;
+#endif /* HAVE_GD_PNG */
}
/* }}} */
-#endif /* HAVE_GD_PNG */
-
-#ifdef HAVE_GD_GIF
/* {{{ proto int imagecreatefromgif(string filename)
Create a new image from GIF file or URL */
PHP_FUNCTION(imagecreatefromgif )
{
+#ifdef HAVE_GD_GIF
zval **file;
gdImagePtr im;
char *fn=NULL;
@@ -577,6 +574,10 @@
RETURN_FALSE;
}
ZEND_REGISTER_RESOURCE(return_value, im, GDG(le_gd));
+#else /* HAVE_GD_GIF */
+ php_error(E_WARNING, "ImageCreateFromGif: No GIF support in this PHP build");
+ RETURN_FALSE;
+#endif /* HAVE_GD_GIF */
}
/* }}} */
@@ -584,6 +585,7 @@
Output GIF image to browser or file */
PHP_FUNCTION(imagegif)
{
+#ifdef HAVE_GD_GIF
zval **imgind, **file;
gdImagePtr im;
char *fn=NULL;
@@ -651,17 +653,19 @@
}
RETURN_TRUE;
+#else /* HAVE_GD_GIF */
+ php_error(E_WARNING, "ImageGif: No GIF support in this PHP build");
+ RETURN_FALSE;
+#endif /* HAVE_GD_GIF */
}
/* }}} */
-#endif /* HAVE_GD_GIF */
-
-#ifdef HAVE_GD_JPG
/* {{{ proto int imagecreatefromjpeg(string filename)
Create a new image from JPEG file or URL */
PHP_FUNCTION(imagecreatefromjpeg)
{
+#ifdef HAVE_GD_JPG
zval **file;
gdImagePtr im;
char *fn=NULL;
@@ -694,6 +698,10 @@
RETURN_FALSE;
}
ZEND_REGISTER_RESOURCE(return_value, im, GDG(le_gd));
+#else /* HAVE_GD_JPG */
+ php_error(E_WARNING, "ImageCreateFromJpeg: No JPG support in this PHP build");
+ RETURN_FALSE;
+#endif /* HAVE_GD_JPG */
}
/* }}} */
@@ -701,6 +709,7 @@
Output JPEG image to browser or file */
PHP_FUNCTION(imagejpeg)
{
+#ifdef HAVE_GD_JPG
zval **imgind, **file, **qual;
gdImagePtr im;
char *fn=NULL;
@@ -765,11 +774,13 @@
/* the temporary file is automatically deleted */
}
RETURN_TRUE;
+#else /* HAVE_GD_JPG */
+ php_error(E_WARNING, "ImageJpeg: No JPG support in this PHP build");
+ RETURN_FALSE;
+#endif /* HAVE_GD_JPG */
}
/* }}} */
-#endif
-
/* {{{ proto int imagedestroy(int im)
Destroy an image */
PHP_FUNCTION(imagedestroy)
@@ -1820,15 +1831,20 @@
/* }}} */
#ifdef ENABLE_GD_TTF
-
#define TTFTEXT_DRAW 0
#define TTFTEXT_BBOX 1
+#endif
/* {{{ proto array imagettfbbox(int size, int angle, string font_file, string text)
Give the bounding box of a text using TrueType fonts */
PHP_FUNCTION(imagettfbbox)
{
+#ifdef ENABLE_GD_TTF
php_imagettftext_common(INTERNAL_FUNCTION_PARAM_PASSTHRU, TTFTEXT_BBOX);
+#else
+ php_error(E_WARNING, "ImageTtfBBox: No TTF support in this PHP build");
+ RETURN_FALSE;
+#endif
}
/* }}} */
@@ -1836,10 +1852,16 @@
Write text to the image using a TrueType font */
PHP_FUNCTION(imagettftext)
{
+#ifdef ENABLE_GD_TTF
php_imagettftext_common(INTERNAL_FUNCTION_PARAM_PASSTHRU, TTFTEXT_DRAW);
+#else
+ php_error(E_WARNING, "ImageTtfText: No TTF support in this PHP build");
+ RETURN_FALSE;
+#endif
}
/* }}} */
+#ifdef ENABLE_GD_TTF
static
void php_imagettftext_common(INTERNAL_FUNCTION_PARAMETERS, int mode)
{
@@ -1918,10 +1940,13 @@
T1_DeleteEncoding(enc);
}
+#endif
+
/* {{{ proto int imagepsloadfont(string pathname)
Load a new font from specified file */
PHP_FUNCTION(imagepsloadfont)
{
+#if HAVE_LIBT1
zval **file;
int f_ind;
int *font;
@@ -1957,6 +1982,10 @@
font = (int *) emalloc(sizeof(int));
*font = f_ind;
ZEND_REGISTER_RESOURCE(return_value, font, GDG(le_ps_font));
+#else
+ php_error(E_WARNING, "ImagePsLoadFont: No T1lib support in this PHP build");
+ RETURN_FALSE;
+#endif
}
/* }}} */
@@ -1966,6 +1995,7 @@
/*
PHP_FUNCTION(imagepscopyfont)
{
+#if HAVE_LIBT1
pval *fnt;
int l_ind, type;
gd_ps_font *nf_ind, *of_ind;
@@ -2012,6 +2042,10 @@
nf_ind->extend = 1;
l_ind = zend_list_insert(nf_ind, GDG(le_ps_font));
RETURN_LONG(l_ind);
+#else
+ php_error(E_WARNING, "ImagePsCopyFont: No T1lib support in this PHP build");
+ RETURN_FALSE;
+#endif
}
*/
/* }}} */
@@ -2020,6 +2054,7 @@
Free memory used by a font */
PHP_FUNCTION(imagepsfreefont)
{
+#if HAVE_LIBT1
zval **fnt;
int *f_ind;
@@ -2031,6 +2066,10 @@
zend_list_delete((*fnt)->value.lval);
RETURN_TRUE;
+#else
+ php_error(E_WARNING, "ImagePsFreeFont: No T1lib support in this PHP build");
+ RETURN_FALSE;
+#endif
}
/* }}} */
@@ -2038,6 +2077,7 @@
To change a fonts character encoding vector */
PHP_FUNCTION(imagepsencodefont)
{
+#if HAVE_LIBT1
zval **fnt, **enc;
char **enc_vector;
int *f_ind;
@@ -2063,6 +2103,10 @@
}
zend_list_insert(enc_vector, GDG(le_ps_enc));
RETURN_TRUE;
+#else
+ php_error(E_WARNING, "ImagePsEncodeFont: No T1lib support in this PHP build");
+ RETURN_FALSE;
+#endif
}
/* }}} */
@@ -2070,6 +2114,7 @@
Extend or or condense (if extend < 1) a font */
PHP_FUNCTION(imagepsextendfont)
{
+#if HAVE_LIBT1
zval **fnt, **ext;
int *f_ind;
@@ -2084,6 +2129,10 @@
if (T1_ExtendFont(*f_ind, (*ext)->value.dval) != 0) RETURN_FALSE;
RETURN_TRUE;
+#else
+ php_error(E_WARNING, "ImagePsExtendFont: No T1lib support in this PHP build");
+ RETURN_FALSE;
+#endif
}
/* }}} */
@@ -2091,6 +2140,7 @@
Slant a font */
PHP_FUNCTION(imagepsslantfont)
{
+#if HAVE_LIBT1
zval **fnt, **slt;
int *f_ind;
@@ -2104,6 +2154,10 @@
if (T1_SlantFont(*f_ind, (*slt)->value.dval) != 0) RETURN_FALSE;
RETURN_TRUE;
+#else
+ php_error(E_WARNING, "ImagePsSlantFont: No T1lib support in this PHP build");
+ RETURN_FALSE;
+#endif
}
/* }}} */
@@ -2111,6 +2165,7 @@
Rasterize a string over an image */
PHP_FUNCTION(imagepstext)
{
+#if HAVE_LIBT1
zval **img, **str, **fnt, **sz, **fg, **bg, **sp, **px, **py, **aas, **wd, **ang;
int i, j, x, y;
int space;
@@ -2254,6 +2309,10 @@
add_next_index_long(return_value, str_img->metrics.rightSideBearing);
add_next_index_long(return_value, str_img->metrics.ascent);
+#else
+ php_error(E_WARNING, "ImagePsText: No T1lib support in this PHP build");
+ RETURN_FALSE;
+#endif
}
/* }}} */
@@ -2261,6 +2320,7 @@
Return the bounding box needed by a string if rasterized */
PHP_FUNCTION(imagepsbbox)
{
+#if HAVE_LIBT1
zval **str, **fnt, **sz, **sp, **wd, **ang;
int i, space, add_width, char_width, amount_kern;
int cur_x, cur_y, dx, dy;
@@ -2361,10 +2421,12 @@
add_next_index_long(return_value, (int) ceil(((double) str_bbox.lly)*(*sz)->value.lval/1000));
add_next_index_long(return_value, (int) ceil(((double) str_bbox.urx)*(*sz)->value.lval/1000));
add_next_index_long(return_value, (int) ceil(((double) str_bbox.ury)*(*sz)->value.lval/1000));
+#else
+ php_error(E_WARNING, "ImagePsBBox: No T1lib support in this PHP build");
+ RETURN_FALSE;
+#endif
}
/* }}} */
-
-#endif /* HAVE_LIBT1 */
#endif /* HAVE_LIBGD */
Index: php4/ext/gd/gdt1.h
diff -u php4/ext/gd/gdt1.h:1.4 php4/ext/gd/gdt1.h:1.5
--- php4/ext/gd/gdt1.h:1.4 Thu Feb 24 22:43:51 2000
+++ php4/ext/gd/gdt1.h Tue May 2 07:10:51 2000
@@ -17,22 +17,11 @@
+----------------------------------------------------------------------+
*/
-/* $Id: gdt1.h,v 1.4 2000/02/25 06:43:51 jah Exp $ */
+/* $Id: gdt1.h,v 1.5 2000/05/02 14:10:51 hholzgra Exp $ */
#if HAVE_LIBT1
#include <t1lib.h>
-
-PHP_FUNCTION(imagepsloadfont);
-/*
-PHP_FUNCTION(imagepscopyfont);
-*/
-PHP_FUNCTION(imagepsfreefont);
-PHP_FUNCTION(imagepsencodefont);
-PHP_FUNCTION(imagepsextendfont);
-PHP_FUNCTION(imagepsslantfont);
-PHP_FUNCTION(imagepstext);
-PHP_FUNCTION(imagepsbbox);
extern void php_free_ps_font(int *);
extern void php_free_ps_enc(char **);
Index: php4/ext/gd/php_gd.h
diff -u php4/ext/gd/php_gd.h:1.6 php4/ext/gd/php_gd.h:1.7
--- php4/ext/gd/php_gd.h:1.6 Sun Mar 12 21:58:50 2000
+++ php4/ext/gd/php_gd.h Tue May 2 07:10:51 2000
@@ -29,7 +29,7 @@
*/
-/* $Id: php_gd.h,v 1.6 2000/03/13 05:58:50 rasmus Exp $ */
+/* $Id: php_gd.h,v 1.7 2000/05/02 14:10:51 hholzgra Exp $ */
#ifndef _PHP_GD_H
#define _PHP_GD_H
@@ -114,10 +114,18 @@
PHP_FUNCTION(imagepng);
void php_gdimagecharup(gdImagePtr, gdFontPtr, int, int, int, int);
PHP_FUNCTION(imagedashedline);
-#ifdef ENABLE_GD_TTF
PHP_FUNCTION(imagettfbbox);
PHP_FUNCTION(imagettftext);
-#endif
+PHP_FUNCTION(imagepsloadfont);
+/*
+PHP_FUNCTION(imagepscopyfont);
+*/
+PHP_FUNCTION(imagepsfreefont);
+PHP_FUNCTION(imagepsencodefont);
+PHP_FUNCTION(imagepsextendfont);
+PHP_FUNCTION(imagepsslantfont);
+PHP_FUNCTION(imagepstext);
+PHP_FUNCTION(imagepsbbox);
PHPAPI int phpi_get_le_gd(void);