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

后端 未结 7 1580
长情又很酷
长情又很酷 2020-12-01 14:34

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?

7条回答
  •  爱一瞬间的悲伤
    2020-12-01 15:34

    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.

提交回复
热议问题