$img_name = $경로; // 새로운 그림地址 $image = file_get_contents($path); $info = getimagesize($path); $im = imagecreatefromstring($image); $너비 = $정보[0]; $높이 = $정보[1]; for($i=0;$i<$height;$i+=1){ for($j=0;$j<$width;$j+=1){ $rgb = ImageColorAt($im, $j, $ 나); $r = ($rgb >> 16) & 0xFF; $g = ($rgb >> 8) & 0xFF; $b = $rgb & 0xFF; if(intval($r)>140 && $g >140 && $b>140){ $hex = imagecolorallocate($im, 255, 255, 255); imagesetpixel($im,$j, $i, $hex); } } } $white = imagecolorallocate($im , 255 , 255 , imagefill($im, 0, 0, $white);//캔버스를 흰색으로 염색 imagecolortransparent($im, $white);//이미지의 흰색을 투명하게 설정 imagepng($im, $img_name);//이미지 생성 return true;
업로드된 이미지 배경을 투명색으로 변경
추천
출처blog.csdn.net/xyy_forever/article/details/107578179
추천
행