How do you convert an image to black and white in PHP
Using the php gd library:
imagefilter($im, IMG_FILTER_GRAYSCALE);
imagefilter($im, IMG_FILTER_CONTRAST, -100);
Check the user comments in the link above for more examples.
Simply round the grayscale color to either black or white.
float gray = (r + g + b) / 3
if(gray > 0x7F) return 0xFF;
return 0x00;