AC_MSG_RESULT(yes (static))
AC_ADD_LIBRARY_WITH_PATH(gd, $GD_LIB)
fi
+ old_LDFLAGS=$LDFLAGS
+ LDFLAGS="$LDFLAGS -L$GD_LIB"
+ old_LIBS=$LIBS
AC_CHECK_LIB(gd, gdImageString16, [ AC_DEFINE(HAVE_LIBGD13) ])
+ LIBS="$LIBS -lpng -lz"
+ AC_CHECK_LIB(gd, gdImageColorResolve, [AC_DEFINE(HAVE_GDIMAGECOLORRESOLVE,1)])
+ AC_CHECK_LIB(gd, gdImageCreateFromPng, [AC_DEFINE(HAVE_GD_PNG, 1)])
+
+ LIBS=$old_LIBS
+ LDFLAGS=$old_LDFLAGS
+ if test "$ac_cv_lib_gd_gdImageCreateFromPng" = "yes"; then
+ AC_ADD_LIBRARY(png)
+ AC_ADD_LIBRARY(z)
+ fi
ac_cv_lib_gd_gdImageLine=yes
else
AC_MSG_ERROR([Unable to find libgd.(a|so) anywhere under $withval])
if test "$shared" = "yes"; then
GD_LIBS="$GD_LIBS -lfreetype"
GD_LFLAGS="$GD_LFLAGS -L$FREETYPE_DIR/lib"
- GD_INCLUDES="$GD_INCLUDES -I$FREETYPE_DIR/include"
else
AC_ADD_LIBRARY_WITH_PATH(freetype, $FREETYPE_DIR/lib)
- AC_ADD_INCLUDE($FREETYPE_DIR/include)
fi
+ AC_ADD_INCLUDE($FREETYPE_DIR/include)
AC_MSG_RESULT(yes)
else
if test -n "$TTF_DIR" ; then
if test "$shared" = "yes"; then
GD_LIBS="$GD_LIBS -lttf"
GD_LFLAGS="$GD_LFLAGS -L$TTF_DIR/lib"
- GD_INCLUDES="$GD_INCLUDES -I$TTF_DIR/include"
else
AC_ADD_LIBRARY_WITH_PATH(ttf, $TTF_DIR/lib)
- AC_ADD_INCLUDE($TTF_DIR/include)
fi
+ AC_ADD_INCLUDE($TTF_DIR/include)
AC_MSG_RESULT(yes)
else
AC_MSG_RESULT(no)
AC_MSG_RESULT(no)
])
+ AC_EXPAND_PATH($GD_INCLUDE, GD_INCLUDE)
+ AC_ADD_INCLUDE($GD_INCLUDE)
PHP_EXTENSION(gd, $shared)
if test "$shared" != "yes"; then
- AC_ADD_INCLUDE($GD_INCLUDE)
GD_STATIC="libphpext_gd.la"
else
- AC_EXPAND_PATH($GD_INCLUDE, GD_INCLUDE)
- if test -n "$GD_INCLUDE"; then
- GD_INCLUDES="$GD_INCLUDES -I$GD_INCLUDE"
- fi
GD_SHARED="gd.la"
fi
fi
AC_SUBST(GD_LFLAGS)
AC_SUBST(GD_LIBS)
-AC_SUBST(GD_INCLUDES)
AC_SUBST(GD_STATIC)
AC_SUBST(GD_SHARED)
PHP_FE(imagecopy, NULL)
PHP_FE(imagecopyresized, NULL)
PHP_FE(imagecreate, NULL)
+#ifdef HAVE_GD_PNG
+ PHP_FE(imagecreatefrompng, NULL)
+ PHP_FE(imagepng, NULL)
+#else
PHP_FE(imagecreatefromgif, NULL)
+ PHP_FE(imagegif, NULL)
+#endif
PHP_FE(imagedestroy, NULL)
PHP_FE(imagefill, NULL)
PHP_FE(imagefilledpolygon, NULL)
PHP_FE(imagefilltoborder, NULL)
PHP_FE(imagefontwidth, NULL)
PHP_FE(imagefontheight, NULL)
- PHP_FE(imagegif, NULL)
PHP_FE(imageinterlace, NULL)
PHP_FE(imageline, NULL)
PHP_FE(imageloadfont, NULL)
return GD_GLOBAL(le_gd);
}
+#ifndef HAVE_GDIMAGECOLORRESOLVE
+
/********************************************************************/
/* gdImageColorResolve is a replacement for the old fragment: */
/* */
return op; /* Return newly allocated color */
}
+#endif
+
void php3_free_gd_font(gdFontPtr fp)
{
if (fp->data) {
}
/* }}} */
+#ifdef HAVE_GD_PNG
+
+/* {{{ proto int imagecreatefrompng(string filename)
+Create a new image from file or URL */
+void php3_imagecreatefrompng (INTERNAL_FUNCTION_PARAMETERS) {
+ pval *file;
+ int ind;
+ gdImagePtr im;
+ char *fn=NULL;
+ FILE *fp;
+ int issock=0, socketd=0;
+ GD_TLS_VARS;
+ if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &file) == FAILURE) {
+ WRONG_PARAM_COUNT;
+ }
+ convert_to_string(file);
+ fn = file->value.str.val;
+#if WIN32|WINNT
+ fp = fopen(file->value.str.val, "rb");
+#else
+ fp = php3_fopen_wrapper(file->value.str.val, "r", IGNORE_PATH|IGNORE_URL_WIN, &issock, &socketd);
+#endif
+ if (!fp) {
+ php3_strip_url_passwd(fn);
+ php3_error(E_WARNING,
+ "ImageCreateFromPng: Unable to open %s for reading", fn);
+ RETURN_FALSE;
+ }
+ im = gdImageCreateFromPng (fp);
+ fflush(fp);
+ fclose(fp);
+ ind = php3_list_insert(im, GD_GLOBAL(le_gd));
+ RETURN_LONG(ind);
+}
+/* }}} */
+
+/* {{{ proto int imagepng(int im, string filename)
+Output image to browser or file */
+void php3_imagepng (INTERNAL_FUNCTION_PARAMETERS) {
+ pval *imgind, *file;
+ gdImagePtr im;
+ char *fn=NULL;
+ FILE *fp;
+ int argc;
+ int ind_type;
+ int output=1;
+ GD_TLS_VARS;
+ argc = ARG_COUNT(ht);
+ if (argc < 1 || argc > 2 || getParameters(ht, argc, &imgind, &file) == FAILURE) {
+ WRONG_PARAM_COUNT;
+ }
+ convert_to_long(imgind);
+ if (argc == 2) {
+ convert_to_string(file);
+ fn = file->value.str.val;
+ if (!fn || fn == empty_string || _php3_check_open_basedir(fn)) {
+ php3_error(E_WARNING, "ImagePng: Invalid filename");
+ RETURN_FALSE;
+ }
+ }
+ im = php3_list_find(imgind->value.lval, &ind_type);
+ if (!im || ind_type != GD_GLOBAL(le_gd)) {
+ php3_error(E_WARNING, "ImagePng: unable to find image pointer");
+ RETURN_FALSE;
+ }
+ if (argc == 2) {
+ fp = fopen(fn, "wb");
+ if (!fp) {
+ php3_error(E_WARNING, "ImagePng: unable to open %s for writing", fn);
+ RETURN_FALSE;
+ }
+ gdImagePng (im,fp);
+ fflush(fp);
+ fclose(fp);
+ }
+ else {
+ int b;
+ FILE *tmp;
+ char buf[4096];
+ tmp = tmpfile();
+ if (tmp == NULL) {
+ php3_error(E_WARNING, "Unable to open temporary file");
+ RETURN_FALSE;
+ }
+ output = php3_header();
+ if (output) {
+ gdImagePng (im, tmp);
+ fseek(tmp, 0, SEEK_SET);
+#if APACHE && defined(CHARSET_EBCDIC)
+ /* This is a binary file already: avoid EBCDIC->ASCII conversion */
+ ap_bsetflag(php3_rqst->connection->client, B_EBCDIC2ASCII, 0);
+#endif
+ while ((b = fread(buf, 1, sizeof(buf), tmp)) > 0) {
+ php3_write(buf, b);
+ }
+ }
+ fclose(tmp);
+ /* the temporary file is automatically deleted */
+ }
+ RETURN_TRUE;
+}
+/* }}} */
+
+#else
+
/* {{{ proto int imagecreatefromgif(string filename)
Create a new image from file or URL */
PHP_FUNCTION(imagecreatefromgif )
}
/* }}} */
+/* {{{ proto int imagegif(int im, string filename)
+Output image to browser or file */
+PHP_FUNCTION(imagegif )
+{
+ pval *imgind, *file;
+ gdImagePtr im;
+ char *fn=NULL;
+ FILE *fp;
+ int argc;
+ int ind_type;
+ int output=1;
+ GD_TLS_VARS;
+
+ argc = ARG_COUNT(ht);
+ if (argc < 1 || argc > 2 || getParameters(ht, argc, &imgind, &file) == FAILURE) {
+ WRONG_PARAM_COUNT;
+ }
+
+ convert_to_long(imgind);
+
+ if (argc == 2) {
+ convert_to_string(file);
+ fn = file->value.str.val;
+ if (!fn || fn == empty_string || _php3_check_open_basedir(fn)) {
+ php_error(E_WARNING, "ImageGif: Invalid filename");
+ RETURN_FALSE;
+ }
+ }
+
+ im = php3_list_find(imgind->value.lval, &ind_type);
+ if (!im || ind_type != GD_GLOBAL(le_gd)) {
+ php_error(E_WARNING, "ImageGif: unable to find image pointer");
+ RETURN_FALSE;
+ }
+
+ if (argc == 2) {
+ fp = fopen(fn, "wb");
+ if (!fp) {
+ php_error(E_WARNING, "ImageGif: unable to open %s for writing", fn);
+ RETURN_FALSE;
+ }
+ gdImageGif (im,fp);
+ fflush(fp);
+ fclose(fp);
+ }
+ else {
+ int b;
+ FILE *tmp;
+ char buf[4096];
+
+ tmp = tmpfile();
+ if (tmp == NULL) {
+ php_error(E_WARNING, "Unable to open temporary file");
+ RETURN_FALSE;
+ }
+
+ output = php3_header();
+
+ if (output) {
+ SLS_FETCH();
+
+ gdImageGif (im, tmp);
+ fseek(tmp, 0, SEEK_SET);
+#if APACHE && defined(CHARSET_EBCDIC)
+ /* This is a binary file already: avoid EBCDIC->ASCII conversion */
+ ap_bsetflag(((request_rec *) SG(server_context))->connection->client, B_EBCDIC2ASCII, 0);
+#endif
+ while ((b = fread(buf, 1, sizeof(buf), tmp)) > 0) {
+ php3_write(buf, b);
+ }
+ }
+
+ fclose(tmp);
+ /* the temporary file is automatically deleted */
+ }
+
+ RETURN_TRUE;
+}
+/* }}} */
+
+#endif /* HAVE_IMAGECREATEFROMPNG */
+
/* {{{ proto int imagedestroy(int im)
Destroy an image */
PHP_FUNCTION(imagedestroy)
}
/* }}} */
-/* {{{ proto int imagegif(int im, string filename)
-Output image to browser or file */
-PHP_FUNCTION(imagegif )
-{
- pval *imgind, *file;
- gdImagePtr im;
- char *fn=NULL;
- FILE *fp;
- int argc;
- int ind_type;
- int output=1;
- GD_TLS_VARS;
-
- argc = ARG_COUNT(ht);
- if (argc < 1 || argc > 2 || getParameters(ht, argc, &imgind, &file) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- convert_to_long(imgind);
-
- if (argc == 2) {
- convert_to_string(file);
- fn = file->value.str.val;
- if (!fn || fn == empty_string || _php3_check_open_basedir(fn)) {
- php_error(E_WARNING, "ImageGif: Invalid filename");
- RETURN_FALSE;
- }
- }
-
- im = php3_list_find(imgind->value.lval, &ind_type);
- if (!im || ind_type != GD_GLOBAL(le_gd)) {
- php_error(E_WARNING, "ImageGif: unable to find image pointer");
- RETURN_FALSE;
- }
-
- if (argc == 2) {
- fp = fopen(fn, "wb");
- if (!fp) {
- php_error(E_WARNING, "ImageGif: unable to open %s for writing", fn);
- RETURN_FALSE;
- }
- gdImageGif (im,fp);
- fflush(fp);
- fclose(fp);
- }
- else {
- int b;
- FILE *tmp;
- char buf[4096];
-
- tmp = tmpfile();
- if (tmp == NULL) {
- php_error(E_WARNING, "Unable to open temporary file");
- RETURN_FALSE;
- }
-
- output = php3_header();
-
- if (output) {
- SLS_FETCH();
-
- gdImageGif (im, tmp);
- fseek(tmp, 0, SEEK_SET);
-#if APACHE && defined(CHARSET_EBCDIC)
- /* This is a binary file already: avoid EBCDIC->ASCII conversion */
- ap_bsetflag(((request_rec *) SG(server_context))->connection->client, B_EBCDIC2ASCII, 0);
-#endif
- while ((b = fread(buf, 1, sizeof(buf), tmp)) > 0) {
- php3_write(buf, b);
- }
- }
-
- fclose(tmp);
- /* the temporary file is automatically deleted */
- }
-
- RETURN_TRUE;
-}
-/* }}} */
-
/* {{{ proto int imagesetpixel(int im, int x, int y, int col)
Set a single pixel */
PHP_FUNCTION(imagesetpixel)