如何在PHP中将图像转换为黑白图像 [英] How do you convert an image to black and white in PHP

查看:404
本文介绍了如何在PHP中将图像转换为黑白图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在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?

推荐答案

只需将灰度颜色变为黑色或白色。

Simply round the grayscale color to either black or white.

float gray = (r + g + b) / 3
if(gray > 0x7F) return 0xFF;
return 0x00;

这篇关于如何在PHP中将图像转换为黑白图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆