Hi everybody!
https://bugs.php.net/73317 is still unresolved, and I'm not sure how
to resolve it.
TL;DR: the $threshold parameter of image2wbmp()
is supposed to specify a
brightness threshold for the required black and white conversion of
the image. However, as of PHP 5.0.0 it is actually interpreted as the
foreground color; all other colors are treated as background. This
makes image2wbmp()
basically identical to imagewbmp()
.
Any suggestions on how to proceed here?
--
Christoph M. Becker
Hi
2018-04-05 14:04 GMT+02:00 Christoph M. Becker cmbecker69@gmx.de:
Hi everybody!
https://bugs.php.net/73317 is still unresolved, and I'm not sure how
to resolve it.TL;DR: the $threshold parameter of
image2wbmp()
is supposed to specify a
brightness threshold for the required black and white conversion of
the image. However, as of PHP 5.0.0 it is actually interpreted as the
foreground color; all other colors are treated as background. This
makesimage2wbmp()
basically identical toimagewbmp()
.Any suggestions on how to proceed here?
If thats the case that its basically identical, then a PHP_DEP_FE
should be sufficient for image2wbmp()
and a removal in future version,
given its a rarely used function and migration is easy, even 7.4 could
potentially be fine for removal.
--
regards,
Kalle Sommer Nielsen
kalle@php.net
2018-04-05 14:04 GMT+02:00 Christoph M. Becker cmbecker69@gmx.de:
https://bugs.php.net/73317 is still unresolved, and I'm not sure how
to resolve it.TL;DR: the $threshold parameter of
image2wbmp()
is supposed to specify a
brightness threshold for the required black and white conversion of
the image. However, as of PHP 5.0.0 it is actually interpreted as the
foreground color; all other colors are treated as background. This
makesimage2wbmp()
basically identical toimagewbmp()
.If thats the case that its basically identical, then a PHP_DEP_FE
should be sufficient forimage2wbmp()
and a removal in future version,
given its a rarely used function and migration is easy, even 7.4 could
potentially be fine for removal.
Thanks, Kalle!
To clarify the behavioral problem: image2wbmp()
is supposed to use
_php_image_bw_convert() to do the conversion. However, that does not
happen anymore since the commit[1] I've mentioned in the bug report.
The problem is that the fallthrough to case PHP_GDIMG_TYPE_JPEG[2] had
been intended (but not documented!), so that _php_image_bw_convert()
(which is stored in func_p) would have been called, but now
gdImageWBMP()[3] is called directly without converting to a black and
white image according to the given threshold.
It is quite interesting that it took apparently more than ten years
until the bug has been reported[4]. This might be due to nobody using
WBMP (see https://bugs.php.net/76179, though).
Anyhow, I have to agree to the deprecation/removal suggestion, since:
- fixing this 10y old bug is likely to cause more harm than good
- a B/W conversion should be a general feature of GD (or likely
rather libgd) - the B/W conversion[5] is very simplistic, and does not fit to
gdImageGrayScale()'s[6] algorithm[7]
I shall pursue the RFC process.
[1]
http://git.php.net/?p=php-src.git;a=commit;h=cb5c9156c233a260e7a588141863720de82d2926
[2]
https://github.com/php/php-src/commit/cb5c9156c233a260e7a588141863720de82d2926#diff-bdf11f69d3dc3fb9601e59055a169449R1728
[3] http://libgd.github.io/manuals/2.2.5/files/gd_wbmp-c.html#gdImageWBMP
[4] https://bugs.php.net/73317
[5] https://github.com/php/php-src/blob/PHP-7.2.4/ext/gd/gd.c#L4140
[6]
http://libgd.github.io/manuals/2.2.5/files/gd_filter-c.html#gdImageGrayScale
[7]
https://github.com/php/php-src/blob/PHP-7.2.4/ext/gd/libgd/gd_filter.c#L74
--
Christoph M. Becker