diff --git a/ext/gd/config.m4 b/ext/gd/config.m4 index bd087b9675c..c7a253c41d1 100644 --- a/ext/gd/config.m4 +++ b/ext/gd/config.m4 @@ -265,6 +265,7 @@ AC_DEFUN([PHP_GD_CHECK_VERSION],[ PHP_CHECK_LIBRARY(gd, gdImageCreateFromGif, [AC_DEFINE(HAVE_GD_GIF_READ, 1, [ ])], [], [ -L$GD_LIB $GD_SHARED_LIBADD ]) PHP_CHECK_LIBRARY(gd, gdImageGif, [AC_DEFINE(HAVE_GD_GIF_CREATE, 1, [ ])], [], [ -L$GD_LIB $GD_SHARED_LIBADD ]) PHP_CHECK_LIBRARY(gd, gdImageWBMP, [AC_DEFINE(HAVE_GD_WBMP, 1, [ ])], [], [ -L$GD_LIB $GD_SHARED_LIBADD ]) + PHP_CHECK_LIBRARY(gd, gdImageCreateFromWebp, [AC_DEFINE(HAVE_GD_WEBP, 1, [ ])], [], [ -L$GD_LIB $GD_SHARED_LIBADD ]) PHP_CHECK_LIBRARY(gd, gdImageCreateFromJpeg, [AC_DEFINE(HAVE_GD_JPG, 1, [ ])], [], [ -L$GD_LIB $GD_SHARED_LIBADD ]) PHP_CHECK_LIBRARY(gd, gdImageCreateFromXpm, [AC_DEFINE(HAVE_GD_XPM, 1, [ ])], [], [ -L$GD_LIB $GD_SHARED_LIBADD ]) PHP_CHECK_LIBRARY(gd, gdImageCreateFromGd2, [AC_DEFINE(HAVE_GD_GD2, 1, [ ])], [], [ -L$GD_LIB $GD_SHARED_LIBADD ]) diff --git a/ext/gd/gd.c b/ext/gd/gd.c index 2d77d127409..008e797fabf 100644 --- a/ext/gd/gd.c +++ b/ext/gd/gd.c @@ -2411,14 +2411,12 @@ static int _php_image_type (char data[8]) } else if (!memcmp(data, php_sig_gif, 3)) { return PHP_GDIMG_TYPE_GIF; } -/* Temporary disabled, as gdGetC, getmbi and skipheader not exported in system libgd */ -#if HAVE_GD_BUNDLED #ifdef HAVE_GD_WBMP else { gdIOCtx *io_ctx; io_ctx = gdNewDynamicCtxEx(8, data, 0); if (io_ctx) { - if (getmbi((int(*)(void *)) gdGetC, io_ctx) == 0 && skipheader((int(*)(void *)) gdGetC, io_ctx) == 0 ) { + if (getmbi((int(*)(void *)) io_ctx->getC, io_ctx) == 0 && skipheader((int(*)(void *)) io_ctx->getC, io_ctx) == 0 ) { #if HAVE_LIBGD204 io_ctx->gd_free(io_ctx); #else @@ -2434,7 +2432,6 @@ static int _php_image_type (char data[8]) } } } -#endif #endif return -1; #endif diff --git a/ext/gd/libgd/gd_compat.c b/ext/gd/libgd/gd_compat.c index b56329029e6..f3627a1404f 100644 --- a/ext/gd/libgd/gd_compat.c +++ b/ext/gd/libgd/gd_compat.c @@ -33,6 +33,7 @@ const char * gdPngGetVersionString() } #endif +/* Not exported by libgd, copied from gdhelpers.h */ int overflow2(int a, int b) { if(a <= 0 || b <= 0) { @@ -44,3 +45,38 @@ int overflow2(int a, int b) return 0; } +/* Not exported by libgd, copied from wbmp.c */ +int +getmbi (int (*getin) (void *in), void *in) +{ + int i, mbi = 0; + + do + { + i = getin (in); + if (i < 0) + return (-1); + mbi = (mbi << 7) | (i & 0x7f); + } + while (i & 0x80); + + return (mbi); +} + +/* Not exported by libgd, copied from wbmp.c */ +int +skipheader (int (*getin) (void *in), void *in) +{ + int i; + + do + { + i = getin (in); + if (i < 0) + return (-1); + } + while (i & 0x80); + + return (0); +} + diff --git a/ext/gd/libgd/gd_compat.h b/ext/gd/libgd/gd_compat.h index 779e709a638..e8fedf80c50 100644 --- a/ext/gd/libgd/gd_compat.h +++ b/ext/gd/libgd/gd_compat.h @@ -11,6 +11,9 @@ const char * gdPngGetVersionString(); const char * gdJpegGetVersionString(); int gdJpegGetVersionInt(); int overflow2(int a, int b); +int getmbi (int (*getin) (void *in), void *in); +int skipheader (int (*getin) (void *in), void *in); + /* filters section *