我正在尝试创建透明的PNG图像的轮廓。以下是我的代码
//file that i am working with
$file='http://www.google.com/mapfiles/turkey.png';
$im =imagecreatefrompng($file);
imagealphablending($im, false);
imagesavealpha($im, true);
$imw =imagesx($im);
$imh =imagesy($im);
//turkey body color
$bodycolor=imagecolorallocatealpha($im, 144, 144, 144, 50);
//imageholder
$imnew =imagecreatetruecolor($imh, $imh);
imagealphablending($imnew, false);
imagesavealpha($imnew, true);
$transparent_color=imagecolorallocatealpha($imnew, 0, 0, 0, 127);
imagecolortransparent($imnew, $transparent_color);
imagefilledrectangle($imnew, 0, 0, $imh, $imh, $transparent_color);
for ($i=0; $i > 24;
//all not transparent pixels are copied to imageholder
if ($alpha != 127)
{
imagesetpixel($imnew, $i, $j, $bodycolor);
}
}
}
//blur filter
imagefilter($imnew, IMG_FILTER_GAUSSIAN_BLUR);
imagefilter($imnew, IMG_FILTER_GAUSSIAN_BLUR);
imagefilter($imnew, IMG_FILTER_GAUSSIAN_BLUR);
header ("Content-type: image/png");
imagepng ($imnew);
imagedestroy ($imnew);
?>
所以,我需要得到边缘模糊的火鸡的轮廓。我需要边缘是模糊的“外面”,所以像素离边缘越远,对于相同的rbg,它就越透明。而imagefilter也将火鸡抬起了一点:)
https://stackoverflow.com/questions/3489884
复制相似问题