This article is from the PHP tutorial column to introduce to you how to change the background color of ID photos in PHP, cut out portraits in PHP, and change the background image in PHP. I hope it will be helpful to you!
php ID photo change background color, php portrait cutout, php change background image
The code is as follows:
';
}
function cleancolor($imgid,$color){
$width = imagesx($imgid);//获取宽
$height = imagesy($imgid);//获取高
for($i=0;$i> 16)&0xff;//取R
$g = ($rgb >> 8)&0xff;//取G
$b = $rgb&0xff;//取B
$randr = 1.5;
$randg = 1;
$randb=1;
//蓝色RGB大致的位置。替换成绿色
if($r=100){
//如果能够精确的计算出要保留位置的,这里可以写绝对的数字
if($i>=$width/2 && $i=$height/2 && $k$old指的是要处理的图片,指定为png格式
$new指的是处理后输出的图片名
$bg指的是背景图
Copy after login
![1632212874646039.png PHP can also change the background color of ID photos, come and learn!](https://img.php.cn/upload/image/616/879/436/1632212874646039.png)
Author:TANKING
Date:2020-05-07
Web:http://www.likeyunba.com/
WeChat:face6009
Recommended study:《 PHP video tutorial》
The above is the detailed content of PHP can also change the background color of ID photos, come and learn!. For more information, please follow other related articles on the PHP Chinese website!