PHP怎么把图上这个黑框去掉

img


<?php
Image($_REQUEST["qq"],'tx/4.png',30,260,0,0.15);
header('content-type:image/png;');
$content=file_get_contents("tx/3.png");
echo $content;
function Image($qq,$dst_path,$xb,$yb,$xz,$dx){
getImg('http://q1.qlogo.cn/g?b=qq&nk='.$qq.'&s=640','tx/2.jpg');
$filename = 'tx/2.jpg';
$percent = $dx;
header('Content-type: image/jpeg');
list($width, $height) = getimagesize($filename);   //取得图像大小
$newwidth = $width * $percent;
$newheight = $height * $percent;
$thumb = imagecreatetruecolor($newwidth, $newheight);   //新建一个真彩色图像
$original = getimagesize($filename);
switch($original[2])
{
case 1 : $source = imagecreatefromgif($filename);
break;
case 2 : $source = imagecreatefromjpeg($filename);
break;
case 3 : $source = imagecreatefrompng($filename);   //由文件或 URL 创建一个新图象
break;
default:
return false;
break;
}
imagecopyresampled($thumb, $source, 0, 0, 0, 0, $newwidth,  //重采样拷贝部分图像并调整大小
$newheight, $width, $height);
imagepng($thumb,"tx/2.png");   // 以 PNG 格式将图像输出到浏览器或文件
$imgpath="tx/2.png";
$ext = pathinfo($imgpath);  //返回文件路径的信息
$src_img = null;
$original = getimagesize($imgpath);
switch($original[2])
{
case 1 : $src_img = imagecreatefromgif($imgpath);
break;
case 2 : $src_img = imagecreatefromjpeg($imgpath);
break;
case 3 : $src_img = imagecreatefrompng($imgpath);
break;
default:
return false;
break;
}
$wh = getimagesize($imgpath);
$w  = $wh[0];
$h  = $wh[1];
$w = $h = min($w, $h);  //找出最小值
$image = imagecreatetruecolor($w, $h);
$bg = imagecolorallocatealpha($image, 127, 127, 127, 127);   //为一幅图像分配颜色 + alpha
imagesavealpha($image, true);  //设置标记以在保存 PNG 图像时保存完整的 alpha 通道信息(与单一透明色相反)
imagefill($image, 0, 0, $bg);  // 区域填充
$r = $w / 2;
for ($x = 0; $x < $w; $x++) {
for ($y = 0; $y < $h; $y++) {
$rgbColor = imagecolorat($src_img, $x, $y);   //取得某像素的颜色索引值
if (((($x-$r) * ($x-$r) + ($y-$r) * ($y-$r)) < ($r*$r))) {
imagesetpixel($image, $x, $y, $rgbColor);  //画一个单一像素
}
}
}
$src = imagerotate($image, $xz, 0);  //边框  //用给定角度旋转图像
$hz = substr(strrchr($dst_path, '.'), 1);
$dst_path =$dst_path;
$dst = imagecreatefromstring(file_get_contents($dst_path));  //从字符串中的图像流新建一图像
imagecopy($dst, $src, $xb,$yb, 0, 0, $w, $h);
imagepng($dst,"tx/3.png");
}

function getImg($url, $filename){
    //去除URL连接上面可能的引号
    $hander = curl_init();
    $fp = fopen($filename, 'wb');
    curl_setopt($hander, CURLOPT_URL, $url);
    curl_setopt($hander, CURLOPT_FILE, $fp);
    curl_setopt($hander, CURLOPT_HEADER, 0);
    curl_setopt($hander, CURLOPT_FOLLOWLOCATION, 1);
    curl_setopt($hander, CURLOPT_TIMEOUT, 60);
    curl_exec($hander);
    curl_close($hander);
    fclose($fp);
    return true;
}

这个应该没办法去掉