我想让 PHP 中预定义多边形之外的任何东西都透明。比方说,你有你的头部形状,那么图像的任何其他部分都应该被装箱。非常感谢!为了让自己清楚,这是我一直在研究的一些代码:
$dat = dirname(__FILE__)."/foto_".time().".png";
$img = imagecreatefrompng("foto.png");
$points = array(93,36,147,1,255,-5,294,37,332,114,327,189,315,249,303,291,290,327,260,360,205,404,165,407,131,376,86,325,62,236,61,155,66,96,77,57,87,45);
$schwarz = ImageColorAllocate ($img, 0, 0, 0);
imagefilledpolygon($img, $points, count($points)/2, $schwarz);
imagepng($img, $dat);
Run Code Online (Sandbox Code Playgroud)