Skip to content

ext/gd: Make TGA always available #19105

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions ext/gd/config.m4
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,6 @@ AC_DEFUN([PHP_GD_CHECK_VERSION],[
PHP_GD_CHECK_FORMAT([Jpeg], [AC_DEFINE([HAVE_GD_JPG], [1])])
PHP_GD_CHECK_FORMAT([Xpm], [AC_DEFINE([HAVE_GD_XPM], [1])])
PHP_GD_CHECK_FORMAT([Bmp], [AC_DEFINE([HAVE_GD_BMP], [1])])
PHP_GD_CHECK_FORMAT([Tga], [AC_DEFINE([HAVE_GD_TGA], [1])])
PHP_CHECK_LIBRARY([gd], [gdFontCacheShutdown],
[AC_DEFINE([HAVE_GD_FREETYPE], [1])],
[],
Expand Down Expand Up @@ -265,8 +264,6 @@ dnl These are always available with bundled library
[Define to 1 if gd extension has PNG support.])
AC_DEFINE([HAVE_GD_BMP], [1],
[Define to 1 if gd extension has BMP support.])
AC_DEFINE([HAVE_GD_TGA], [1],
[Define to 1 if gd extension has TGA support.])

dnl Various checks for GD features
PHP_SETUP_ZLIB([GD_SHARED_LIBADD])
Expand Down
1 change: 0 additions & 1 deletion ext/gd/config.w32
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ if (PHP_GD != "no") {
AC_DEFINE('HAVE_GD_BUNDLED', 1, "Define to 1 if gd extension uses GD library bundled in PHP.");
AC_DEFINE('HAVE_GD_PNG', 1, "Define to 1 if gd extension has PNG support.");
AC_DEFINE('HAVE_GD_BMP', 1, "Define to 1 if gd extension has BMP support.");
AC_DEFINE('HAVE_GD_TGA', 1, "Define to 1 if gd extension has TGA support.");
AC_DEFINE('HAVE_LIBPNG', 1, "Define to 1 if you have the libpng library.");
AC_DEFINE('HAVE_LIBJPEG', 1, "Define to 1 if you have the libjpeg library.");
AC_DEFINE('HAVE_GD_JPG', 1, "Define to 1 if gd extension has JPEG support.");
Expand Down
10 changes: 0 additions & 10 deletions ext/gd/gd.c
Original file line number Diff line number Diff line change
Expand Up @@ -449,9 +449,7 @@ PHP_MINFO_FUNCTION(gd)
#ifdef HAVE_GD_AVIF
php_info_print_table_row(2, "AVIF Support", "enabled");
#endif
#ifdef HAVE_GD_TGA
php_info_print_table_row(2, "TGA Read Support", "enabled");
#endif
php_info_print_table_end();
DISPLAY_INI_ENTRIES();
}
Expand Down Expand Up @@ -506,11 +504,7 @@ PHP_FUNCTION(gd_info)
#else
add_assoc_bool(return_value, "AVIF Support", 0);
#endif
#ifdef HAVE_GD_TGA
add_assoc_bool(return_value, "TGA Read Support", 1);
#else
add_assoc_bool(return_value, "TGA Read Support", 0);
#endif
#ifdef USE_GD_JISX0208
add_assoc_bool(return_value, "JIS-mapped Japanese Font Support", 1);
#else
Expand Down Expand Up @@ -1338,9 +1332,7 @@ PHP_FUNCTION(imagetypes)
#ifdef HAVE_GD_BMP
ret |= PHP_IMG_BMP;
#endif
#ifdef HAVE_GD_TGA
ret |= PHP_IMG_TGA;
#endif
#ifdef HAVE_GD_AVIF
ret |= PHP_IMG_AVIF;
#endif
Expand Down Expand Up @@ -1733,14 +1725,12 @@ PHP_FUNCTION(imagecreatefrombmp)
/* }}} */
#endif

#ifdef HAVE_GD_TGA
/* {{{ Create a new image from TGA file or URL */
PHP_FUNCTION(imagecreatefromtga)
{
_php_image_create_from(INTERNAL_FUNCTION_PARAM_PASSTHRU, PHP_GDIMG_TYPE_TGA, "TGA", gdImageCreateFromTga, gdImageCreateFromTgaCtx);
}
/* }}} */
#endif

/* {{{ _php_image_output */
static void _php_image_output(INTERNAL_FUNCTION_PARAMETERS, int image_type, const char *tn)
Expand Down
2 changes: 0 additions & 2 deletions ext/gd/gd.stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -594,9 +594,7 @@ function imagecreatefromgd2part(string $filename, int $x, int $y, int $width, in
function imagecreatefrombmp(string $filename): GdImage|false {}
#endif

#ifdef HAVE_GD_TGA
function imagecreatefromtga(string $filename): GdImage|false {}
#endif

function imagexbm(GdImage $image, ?string $filename, ?int $foreground_color = null): bool {}

Expand Down
12 changes: 2 additions & 10 deletions ext/gd/gd_arginfo.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion ext/gd/tests/imagecreatefromtga_basic.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ imagecreatefromtga() - basic functionality
gd
--SKIPIF--
<?php
if (!(imagetypes() & IMG_TGA)) die('skip TGA support required');
if (!(imagetypes() & IMG_PNG)) {
die("skip No PNG support");
}
Expand Down
1 change: 0 additions & 1 deletion ext/gd/tests/imagecreatefromtga_variation.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ imagecreatefromtga() - RLE file reading
gd
--SKIPIF--
<?php
if (!(imagetypes() & IMG_TGA)) die('skip TGA support required');
if (!(imagetypes() & IMG_PNG)) {
die("skip No PNG support");
}
Expand Down