php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #72596 imagetypes function won't advertise WEBP support
Submitted: 2016-07-14 12:52 UTC Modified: 2016-07-14 14:13 UTC
From: chris at ocproducts dot com Assigned: cmb (profile)
Status: Closed Package: GD related
PHP Version: Irrelevant OS:
Private report: No CVE-ID: None
 [2016-07-14 12:52 UTC] chris at ocproducts dot com
Description:
------------
The imagetypes function will not return a bitmask value for if WEBP support is available, which is available with read/write since PHP 5.5. All other formats are currently covered (except for GD which is implied, and XBM which is implied by XPM).

Here's the code from PHP7 to confirm...

/* {{{ proto int imagetypes(void)
   Return the types of images supported in a bitfield - 1=GIF, 2=JPEG, 4=PNG, 8=WBMP, 16=XPM */
PHP_FUNCTION(imagetypes)
{
	int ret=0;
	ret = 1;
#ifdef HAVE_GD_JPG
	ret |= 2;
#endif
#ifdef HAVE_GD_PNG
	ret |= 4;
#endif
	ret |= 8;
#if defined(HAVE_GD_XPM)
	ret |= 16;
#endif

	if (zend_parse_parameters_none() == FAILURE) {
		return;
	}

	RETURN_LONG(ret);
}


Personally I'd recommend just dropping the function, given that GD-Info returns details in its report and you can just use function_exists. Removing a function and a set of constants may lower the PHP overhead slightly. But if it stays it should be consistent with what PHP can do.


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-07-14 14:13 UTC] cmb@php.net
-Status: Open +Status: Verified -Assigned To: +Assigned To: cmb
 [2016-07-14 14:13 UTC] cmb@php.net
Thanks for the report.

> Personally I'd recommend just dropping the function, […]

Due to backward compatibility reasons, that would have to be
postponed to a major (or maybe minor) version, and would require
an RFC, and most likely a deprecation phase. The bug would have,
however, to be fixed for PHP 5.6+ anyway.
 [2016-07-14 15:31 UTC] cmb@php.net
Automatic comment on behalf of cmb
Revision: http://git.php.net/?p=php-src.git;a=commit;h=8bb3bd04a9d38c08dce0034ad8fc1263631d28ff
Log: Fix bug #72596: imagetypes function won't advertise WEBP support
 [2016-07-14 15:31 UTC] cmb@php.net
-Status: Verified +Status: Closed
 [2016-07-14 15:38 UTC] cmb@php.net
Automatic comment from SVN on behalf of cmb
Revision: http://svn.php.net/viewvc/?view=revision&revision=339665
Log: Document #72596: imagetypes function won't advertise WEBP support
 [2016-07-14 15:48 UTC] cmb@php.net
Automatic comment from SVN on behalf of cmb
Revision: http://svn.php.net/viewvc/?view=revision&revision=339666
Log: Document #72596: imagetypes function won't advertise WEBP support

Update migration guides.
 [2016-10-17 10:11 UTC] bwoebi@php.net
Automatic comment on behalf of cmb
Revision: http://git.php.net/?p=php-src.git;a=commit;h=8bb3bd04a9d38c08dce0034ad8fc1263631d28ff
Log: Fix bug #72596: imagetypes function won't advertise WEBP support
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Mar 19 11:01:28 2024 UTC