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

- Thread: https://externals.io/message/96342
- Original archive: https://news-web.php.net/php.internals/96342
- Started by Christoph M. Becker on 2016-10-13T17:03:09+00:00
- Messages: 7
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #96342 — Christoph M. Becker — 2016-10-13T17:03:09+00:00

URL: https://externals.io/message/96342#96342

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

---

## #96352 — Kalle Sommer Nielsen — 2016-10-13T20:28:59+00:00

URL: https://externals.io/message/96342#96352 · In reply to: #96342

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

---

## #96354 — Dan Ackroyd — 2016-10-13T21:17:56+00:00

URL: https://externals.io/message/96342#96354 · In reply to: #96342

> 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

---

## #96360 — Kalle Sommer Nielsen — 2016-10-13T22:50:31+00:00

URL: https://externals.io/message/96342#96360 · In reply to: #96354

2016-10-13 23:17 GMT+02:00 Dan Ackroyd <danack@basereality.com>:
> 
> > […]
>
> 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

---

## #96361 — Christoph M. Becker — 2016-10-13T22:56:32+00:00

URL: https://externals.io/message/96342#96361 · In reply to: #96352

> 2016-10-13 19:03 GMT+02:00 Christoph M. Becker <cmbecker69@gmx.de>:
>
> > […]
> 
> +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

---

## #96366 — Christoph M. Becker — 2016-10-14T08:48:20+00:00

URL: https://externals.io/message/96342#96366 · In reply to: #96360

> 2016-10-13 23:17 GMT+02:00 Dan Ackroyd <danack@basereality.com>:
>
> > […]
> 
> 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

---

## #96367 — Pierre Joye — 2016-10-14T10:04:19+00:00

URL: https://externals.io/message/96342#96367 · In reply to: #96342

>
> 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
