PHP Functions for converting image to greyscale and to black and white.
Simply include imagebw.php
in your project and start using
imagegreyscale
and imagebw
functions - see docs below.
/**
* Converts image to greyscale
* @param resource|GdImage $img
*/
function imagegreyscale($img): void;
/**
* Converts image to black and white image
* @param resource|GdImage $img
* @param int $type See BW_ constants
*/
function imagebw($img, int $type): void;
For second parameter of imagebw
a $type
of conversion is needed.
You can use following constants:
/**
* Nearest color
*/
define("BW_NORMAL", 0);
/**
* Floyd/Steinenberg
*/
define("BW_FLOID", 1);
/**
* Stucki
*/
define("BW_STUCKI", 2);
/**
* Burkes
*/
define("BW_BURKES", 3);
/**
* Bayer
*/
define("BW_BAYER", 4);
The library is licensed under GNU/LGPL v2.1, see LICENSE for details.
Jindra Petřík aka JPEXS
Changes in versions are logged in the file CHANGELOG.md