How do you convert an image to black and white in PHP

AnnanFay picture AnnanFay · Oct 31, 2008 · Viewed 29.9k times · Source

How does one go about converting an image to black and white in PHP?

Not just turning it into greyscale but every pixel made black or white?

Answer

Joel Wietelmann picture Joel Wietelmann · Oct 31, 2008

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.