ext/gd: Deprecate png2wbmp() and jpeg2wbmp()

php.internals

Christoph Becker

9 years ago
Hi! I suggest to deprecate png2wbmp() and jpeg2wbmp() as of PHP 7.2 and to remove the functions as of PHP 8.0. Both functions are very special for ext/gd; there are no other direct conversion functions, and even their names do not start with "image" like all other ext/gd functions, except gd_info(). Implementing a fallback in userland would be trivial (besides an issue with image2wbmp(), see <https://bugs.php.net/bug.php?id=73317>). Furthermore, WBMP supposedly isn't really important nowadays. The benefit would be less code and documentation to maintain, and a cleaner interface. Thoughts?
-- Christoph M. Becker

Kalle Sommer Nielsen

9 years ago
Hi 2016-10-13 19:03 GMT+02:00 Christoph M. Becker <cmbecker69@gmx.de>:
> Hi! > > I suggest to deprecate png2wbmp() and jpeg2wbmp() as of PHP 7.2 and to > remove the functions as of PHP 8.0. > > Both functions are very special for ext/gd; there are no other direct > conversion functions, and even their names do not start with "image" > like all other ext/gd functions, except gd_info(). Implementing a > fallback in userland would be trivial (besides an issue with > image2wbmp(), see <https://bugs.php.net/bug.php?id=73317>). > Furthermore, WBMP supposedly isn't really important nowadays.
+1, I even think that 7.3 should have them removed. Besides png2wbmp() and jpeg2wbmp(), I'd like for you to add image2wbmp() to that list too.
-- regards, Kalle Sommer Nielsen kalle@php.net

Christoph Becker

9 years ago
On 13.10.2016 at 22:28, Kalle Sommer Nielsen wrote:
> 2016-10-13 19:03 GMT+02:00 Christoph M. Becker <cmbecker69@gmx.de>: > >> I suggest to deprecate png2wbmp() and jpeg2wbmp() as of PHP 7.2 and to >> remove the functions as of PHP 8.0. >> >> Both functions are very special for ext/gd; there are no other direct >> conversion functions, and even their names do not start with "image" >> like all other ext/gd functions, except gd_info(). Implementing a >> fallback in userland would be trivial (besides an issue with >> image2wbmp(), see <https://bugs.php.net/bug.php?id=73317>). >> Furthermore, WBMP supposedly isn't really important nowadays. > > +1, I even think that 7.3 should have them removed.
Frankly, I think these functions should have been removed with PHP 7.0. However, that didn't happen, and so we'd have to adhere to our release process[1]: * x.y.z to x.y+1.z * API compatibility must be kept (userland)
> Besides png2wbmp() > and jpeg2wbmp(), I'd like for you to add image2wbmp() to that list > too.
Actually, I agree that we should remove this function. However, it is supposed to offer the easy fallback for the other functions, so keeping it would be helpful to provide efficient userland replacements, if it will be fixed[2]. Otherwise it's useless anyway, and we might consider to introduce something like imagefilter($im, IMG_FILTER_BLACK_AND_WHITE, $threshold) [1] <https://wiki.php.net/rfc/releaseprocess> [2] <https://bugs.php.net/bug.php?id=73317>
-- Christoph M. Becker

Dan Ackroyd

9 years ago
On 13 October 2016 at 18:03, Christoph M. Becker <cmbecker69@gmx.de> wrote:
> Implementing a fallback in userland would be trivial
You should do that first, and get at least some people to use them, if you want them deprecated or removed from PHP. cheers Dan

Kalle Sommer Nielsen

9 years ago
2016-10-13 23:17 GMT+02:00 Dan Ackroyd <danack@basereality.com>:
> On 13 October 2016 at 18:03, Christoph M. Becker <cmbecker69@gmx.de> wrote: >> Implementing a fallback in userland would be trivial > > You should do that first, and get at least some people to use them, if > you want them deprecated or removed from PHP.
I don't think this really matters for these so rarely used functions tbh
-- regards, Kalle Sommer Nielsen kalle@php.net

Christoph Becker

9 years ago
On 14.10.2016 at 00:50, Kalle Sommer Nielsen wrote:
> 2016-10-13 23:17 GMT+02:00 Dan Ackroyd <danack@basereality.com>: > >> On 13 October 2016 at 18:03, Christoph M. Becker <cmbecker69@gmx.de> wrote: >> >>> Implementing a fallback in userland would be trivial >> >> You should do that first, and get at least some people to use them, if >> you want them deprecated or removed from PHP. > > I don't think this really matters for these so rarely used functions tbh
Indeed it might be hard to find people still converting to WBMP, let alone finding someone who'd be willing to work with a fallback as long as the functions are in ext/gd. Furthermore a fallback might be as simple as: if (!function_exists('png2wbmp')) { function png2wbmp(string $pngname, string $wbmpname, int $dest_height, int $dest_width, int $threshold) { $im = imagecreatefrompng($pngname); $width = imagesx($im); $height = imagesy($im); $tmp = imagecreate($width, $height); imagecopyresized($tmp, $im, 0, 0, 0, 0, $dest_width, $dest_height, $width, $height); return image2wbmp($tmp, $wbmpname, $threshold); } } In my opinion, there's no need for an external library. The crux would be image2wbmp(); if it won't get fixed, it can't be used here. But in this case I'd prefer a more general solution for converting to black and white according to a given threshold. That might be interesting for other formats (e.g. PNG) as well.
-- Christoph M. Becker

Pierre Joye

9 years ago
On Oct 14, 2016 1:02 AM, "Christoph M. Becker" <cmbecker69@gmx.de> wrote:
> > Hi! > > I suggest to deprecate png2wbmp() and jpeg2wbmp() as of PHP 7.2 and to > remove the functions as of PHP 8.0.
I fully agree. And I oppose to other propositions to remove them (or anything else) in 7.x. Cheers Pierre