我希望能创建一个图像,将头像和另一幅图像叠加在一起。
(我想叠加的图像)
不同的头像具有不同的宽度和高度,我想让PHP脚本根据头像的大小来“拉伸”
这是我目前用于将头像转换为灰度图像并新建图像的脚本:
![我想使用的被禁止的图片](https://istack.dev59.com/bbNLg.webp)
不同的头像具有不同的宽度和高度,我想让PHP脚本根据头像的大小来“拉伸”
banned.png
,覆盖整个头像。这是我目前用于将头像转换为灰度图像并新建图像的脚本:
function ImageToGreyscale($imagepath, $username){
$image_1_file = $imagepath.$username.'.png';
$image_2_file = $imagepath.'/scripting/banned.png';
$image_1_size = getimagesize($image_1_file);
$image_1_w = $image_1_size[0];
$image_1_h = $image_1_size[1];
$image_1 = imagecreatefrompng($image_1_file);
$image_2 = imagecreatefrompng($image_2_file);
imagealphablending($image_1, true);
imagesavealpha($image_1, true);
imagefilter($image_1, IMG_FILTER_GRAYSCALE);
imagecopy($image_1, $image_2, 0, 0, 0, 0, $image_1_w, $image_1_h);
imagepng($image_1, $imagepath.$username.'_banned.png');
imagedestroy($image_1);
我想把红色的“禁止”覆盖在它上面。
这是我想要的结果:
(原始)
(编辑后)
你能帮忙做这个吗?