rfc:image2wbmp

PHP RFC: Deprecate and Remove image2wbmp()

Introduction

ext/gd has two functions to output WBMP 1) images: imagewbmp() and image2wbmp(). Both are supposed to handle the necessary monochrome conversion by different means. While the former function allows the desired foreground color to be specified, the latter function is supposed to take a brightness threshold parameter. However, as of PHP 5.0.0 the threshold parameter of image2wbmp() is treated as foreground color, so both functions are basically identical.

This pointless duplication of functionality could be resolved by fixing image2wbmp() according to the documentation (i.e. treat the third parameter actually as brightness treshold), but

  • fixing this 10+y old bug is likely to cause more harm than good
  • a monochrome conversion should be a general feature of GD (or rather libgd), since it may be useful for other image formats as well (e.g. PNG)
  • the implemented monochrome conversion is very simplistic, and does not fit to gdImageGrayScale()'s algorithm
  • WBMP might be considered obsolete nowadays

Proposal

Therefore, this RFC proposes to:

  1. fix the documentation according to the current implementation
  2. remove superfluous code (most notably _php_image_bw_convert())
  3. deprecate image2wbmp()
  4. finally remove image2wbmp() altogether

Backward Incompatible Changes

After the deprecation, each call to image2wbmp() would issue a deprecated warning. After the removal, each call to image2wbmp() would raise a fatal error.

Proposed PHP Version(s)

Item (1) to (3) of the proposal should target next PHP 7.y (i.e. PHP 7.3), while item (4) (i.e. the actual removal) should target next PHP x (supposedly PHP 8).

Open Issues

None, yet.

Future Scope

None, yet.

Proposed Voting Choices

A single vote will be held to decide whether to implement the proposal. This vote will require a 2/3 supermajority.

Patches and Tests

I'm going to prepare a pull request for the proposed changes targeting next PHP 7.y as soon as possible.

Implementation

After the project is implemented, this section should contain

  1. the version(s) it was merged into
  2. a link to the git commit(s)
  3. a link to the PHP manual entry for the feature

References

Rejected Features

None, yet.

1)
Wireless Application Protocol Bitmap Format; not Windows Bitmap
rfc/image2wbmp.txt · Last modified: 2018/05/11 14:01 by cmb