Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 316
AnnanFay Avatar asked Oct 31 '08 18:10

AnnanFay


1 Answers

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.

like image 151
Joel Wietelmann Avatar answered Sep 19 '22 11:09

Joel Wietelmann