Skip to content

Commit d40b603

Browse files
authored
ext/gd: Make BMP always available (#19115)
- 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. - The HAVE_GD_PNG moved to PHP_GD_PNG Autoconf macro as it is always required when building with bundled libgd.
1 parent ba68cbe commit d40b603

File tree

10 files changed

+3
-48
lines changed

10 files changed

+3
-48
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: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ AC_DEFUN([PHP_GD_PNG],[
6565
PHP_EVAL_LIBLINE([$PNG_LIBS], [GD_SHARED_LIBADD])
6666
PHP_EVAL_INCLINE([$PNG_CFLAGS])
6767
AC_DEFINE([HAVE_LIBPNG], [1], [Define to 1 if you have the libpng library.])
68+
AC_DEFINE([HAVE_GD_PNG], [1], [Define to 1 if gd extension has PNG support.])
6869
])
6970

7071
AC_DEFUN([PHP_GD_AVIF], [
@@ -191,7 +192,6 @@ AC_DEFUN([PHP_GD_CHECK_VERSION],[
191192
PHP_GD_CHECK_FORMAT([Webp], [AC_DEFINE([HAVE_GD_WEBP], [1])])
192193
PHP_GD_CHECK_FORMAT([Jpeg], [AC_DEFINE([HAVE_GD_JPG], [1])])
193194
PHP_GD_CHECK_FORMAT([Xpm], [AC_DEFINE([HAVE_GD_XPM], [1])])
194-
PHP_GD_CHECK_FORMAT([Bmp], [AC_DEFINE([HAVE_GD_BMP], [1])])
195195
PHP_CHECK_LIBRARY([gd], [gdFontCacheShutdown],
196196
[AC_DEFINE([HAVE_GD_FREETYPE], [1])],
197197
[],
@@ -257,13 +257,8 @@ if test "$PHP_GD" != "no"; then
257257
libgd/wbmp.c
258258
"])
259259

260-
dnl These are always available with bundled library
261260
AC_DEFINE([HAVE_GD_BUNDLED], [1],
262261
[Define to 1 if gd extension uses GD library bundled in PHP.])
263-
AC_DEFINE([HAVE_GD_PNG], [1],
264-
[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.])
267262

268263
dnl Various checks for GD features
269264
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.

ext/gd/tests/bug77391.phpt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ gd
55
--SKIPIF--
66
<?php
77
if (!GD_BUNDLED && version_compare(GD_VERSION, '2.2.5', '<=')) die('skip upstream not yet fixed');
8-
if (!(imagetypes() & IMG_BMP)) die('skip BMP support required');
98
?>
109
--FILE--
1110
<?php

ext/gd/tests/imagebmp_basic.phpt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,6 @@
22
imagebmp() - basic functionality
33
--EXTENSIONS--
44
gd
5-
--SKIPIF--
6-
<?php
7-
if (!(imagetypes() & IMG_BMP)) die('skip BMP support required');
8-
?>
95
--FILE--
106
<?php
117
// create an image

ext/gd/tests/imagecreatefrombmp_basic.phpt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ imagecreatefrombmp() - basic functionality
44
gd
55
--SKIPIF--
66
<?php
7-
if (!(imagetypes() & IMG_BMP)) die('skip BMP support required');
87
if (!(imagetypes() & IMG_PNG)) {
98
die("skip No PNG support");
109
}

ext/gd/tests/imagecreatefromstring_bmp.phpt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ imagecreatefromstring() - BMP format
44
gd
55
--SKIPIF--
66
<?php
7-
if (!(imagetypes() & IMG_BMP)) die('skip BMP support required');
87
if (!(imagetypes() & IMG_PNG)) {
98
die("skip No PNG support");
109
}

0 commit comments

Comments
 (0)