Skip to content

Commit a9feb6c

Browse files
committed
ext/gd: Make BMP always available
- When building with bundled libgd, it has support for BMP - When building with external libgd, at least 2.1.0 is required, which has BMP support.
1 parent ba68cbe commit a9feb6c

File tree

6 files changed

+2
-38
lines changed

6 files changed

+2
-38
lines changed

Zend/Optimizer/zend_func_infos.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,9 +131,7 @@ static const func_info_t func_infos[] = {
131131
F1("imagecreatefromgd", MAY_BE_OBJECT|MAY_BE_FALSE),
132132
F1("imagecreatefromgd2", MAY_BE_OBJECT|MAY_BE_FALSE),
133133
F1("imagecreatefromgd2part", MAY_BE_OBJECT|MAY_BE_FALSE),
134-
#if defined(HAVE_GD_BMP)
135134
F1("imagecreatefrombmp", MAY_BE_OBJECT|MAY_BE_FALSE),
136-
#endif
137135
F1("imagecolorsforindex", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_STRING|MAY_BE_ARRAY_OF_LONG),
138136
F1("imagegetclip", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_OF_LONG),
139137
#if defined(HAVE_GD_FREETYPE)

ext/gd/config.m4

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,6 @@ AC_DEFUN([PHP_GD_CHECK_VERSION],[
191191
PHP_GD_CHECK_FORMAT([Webp], [AC_DEFINE([HAVE_GD_WEBP], [1])])
192192
PHP_GD_CHECK_FORMAT([Jpeg], [AC_DEFINE([HAVE_GD_JPG], [1])])
193193
PHP_GD_CHECK_FORMAT([Xpm], [AC_DEFINE([HAVE_GD_XPM], [1])])
194-
PHP_GD_CHECK_FORMAT([Bmp], [AC_DEFINE([HAVE_GD_BMP], [1])])
195194
PHP_CHECK_LIBRARY([gd], [gdFontCacheShutdown],
196195
[AC_DEFINE([HAVE_GD_FREETYPE], [1])],
197196
[],
@@ -262,8 +261,6 @@ dnl These are always available with bundled library
262261
[Define to 1 if gd extension uses GD library bundled in PHP.])
263262
AC_DEFINE([HAVE_GD_PNG], [1],
264263
[Define to 1 if gd extension has PNG support.])
265-
AC_DEFINE([HAVE_GD_BMP], [1],
266-
[Define to 1 if gd extension has BMP support.])
267264

268265
dnl Various checks for GD features
269266
PHP_SETUP_ZLIB([GD_SHARED_LIBADD])

ext/gd/config.w32

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ if (PHP_GD != "no") {
6161
gd_crop.c gd_interpolation.c gd_matrix.c gd_bmp.c gd_tga.c", "gd");
6262
AC_DEFINE('HAVE_GD_BUNDLED', 1, "Define to 1 if gd extension uses GD library bundled in PHP.");
6363
AC_DEFINE('HAVE_GD_PNG', 1, "Define to 1 if gd extension has PNG support.");
64-
AC_DEFINE('HAVE_GD_BMP', 1, "Define to 1 if gd extension has BMP support.");
6564
AC_DEFINE('HAVE_LIBPNG', 1, "Define to 1 if you have the libpng library.");
6665
AC_DEFINE('HAVE_LIBJPEG', 1, "Define to 1 if you have the libjpeg library.");
6766
AC_DEFINE('HAVE_GD_JPG', 1, "Define to 1 if gd extension has JPEG support.");

ext/gd/gd.c

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -443,9 +443,7 @@ PHP_MINFO_FUNCTION(gd)
443443
#ifdef HAVE_GD_WEBP
444444
php_info_print_table_row(2, "WebP Support", "enabled");
445445
#endif
446-
#ifdef HAVE_GD_BMP
447446
php_info_print_table_row(2, "BMP Support", "enabled");
448-
#endif
449447
#ifdef HAVE_GD_AVIF
450448
php_info_print_table_row(2, "AVIF Support", "enabled");
451449
#endif
@@ -494,11 +492,7 @@ PHP_FUNCTION(gd_info)
494492
#else
495493
add_assoc_bool(return_value, "WebP Support", 0);
496494
#endif
497-
#ifdef HAVE_GD_BMP
498495
add_assoc_bool(return_value, "BMP Support", 1);
499-
#else
500-
add_assoc_bool(return_value, "BMP Support", 0);
501-
#endif
502496
#ifdef HAVE_GD_AVIF
503497
add_assoc_bool(return_value, "AVIF Support", 1);
504498
#else
@@ -1329,9 +1323,7 @@ PHP_FUNCTION(imagetypes)
13291323
#ifdef HAVE_GD_WEBP
13301324
ret |= PHP_IMG_WEBP;
13311325
#endif
1332-
#ifdef HAVE_GD_BMP
13331326
ret |= PHP_IMG_BMP;
1334-
#endif
13351327
ret |= PHP_IMG_TGA;
13361328
#ifdef HAVE_GD_AVIF
13371329
ret |= PHP_IMG_AVIF;
@@ -1716,14 +1708,12 @@ PHP_FUNCTION(imagecreatefromgd2part)
17161708
}
17171709
/* }}} */
17181710

1719-
#ifdef HAVE_GD_BMP
17201711
/* {{{ Create a new image from BMP file or URL */
17211712
PHP_FUNCTION(imagecreatefrombmp)
17221713
{
17231714
_php_image_create_from(INTERNAL_FUNCTION_PARAM_PASSTHRU, PHP_GDIMG_TYPE_BMP, "BMP", gdImageCreateFromBmp, gdImageCreateFromBmpCtx);
17241715
}
17251716
/* }}} */
1726-
#endif
17271717

17281718
/* {{{ Create a new image from TGA file or URL */
17291719
PHP_FUNCTION(imagecreatefromtga)
@@ -2117,7 +2107,6 @@ PHP_FUNCTION(imagegd2)
21172107
}
21182108
/* }}} */
21192109

2120-
#ifdef HAVE_GD_BMP
21212110
/* {{{ Output BMP image to browser or file */
21222111
PHP_FUNCTION(imagebmp)
21232112
{
@@ -2148,7 +2137,6 @@ PHP_FUNCTION(imagebmp)
21482137
RETURN_TRUE;
21492138
}
21502139
/* }}} */
2151-
#endif
21522140

21532141
/* {{{ Destroy an image - No effect as of PHP 8.0 */
21542142
PHP_FUNCTION(imagedestroy)

ext/gd/gd.stub.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -589,10 +589,8 @@ function imagecreatefromgd2(string $filename): GdImage|false {}
589589
/** @refcount 1 */
590590
function imagecreatefromgd2part(string $filename, int $x, int $y, int $width, int $height): GdImage|false {}
591591

592-
#ifdef HAVE_GD_BMP
593592
/** @refcount 1 */
594593
function imagecreatefrombmp(string $filename): GdImage|false {}
595-
#endif
596594

597595
function imagecreatefromtga(string $filename): GdImage|false {}
598596

@@ -628,10 +626,8 @@ function imagegd(GdImage $image, ?string $file = null): bool {}
628626

629627
function imagegd2(GdImage $image, ?string $file = null, int $chunk_size = 128, int $mode = IMG_GD2_RAW): bool {}
630628

631-
#ifdef HAVE_GD_BMP
632629
/** @param resource|string|null $file */
633630
function imagebmp(GdImage $image, $file = null, bool $compressed = true): bool {}
634-
#endif
635631

636632
function imagedestroy(GdImage $image): true {}
637633

ext/gd/gd_arginfo.h

Lines changed: 2 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)