以下为TP5.1的示例:
public function repeatimg($uid,$dst_path,$src_path)
{
$path=Env::get('root_path');
//创建源图的实例
$src = imagecreatefromstring(file_get_contents($dst_path));
//创建点的实例
$des = imagecreatefrompng($src_path);
//获取点图片的宽高
list($point_w, $point_h) = getimagesize($src_path);
//重点:png透明用这个函数
imagecopy($src, $des, 0, 0, 0, 0, $point_w, $point_h);
imagecopy($src, $des, 0, 0, 0, 0, $point_w, $point_h);
//header('Content-Type: image/jpeg');
imagejpeg($src,$path.'/static/upload/user/'.$uid.'.png');
imagedestroy($src);
imagedestroy($des);
$new_name='/static/upload/user/'.$uid.'.png';
return $new_name;
}