private function imageMerge($file1,$file2){
$filets['width'] = '300';//宽
$filets['height'] = '300';//高
$filets['x'] = ''; //x轴
$filets['y'] =''; //y轴
//本地的绝对路径
$dst_path = $file1;//背景图
$src_path= $file2; //头像
$hz = substr(strrchr($dst_path, '.'), 1);
$path = ‘C:/Users/pc/Desktop/hrchengtupian/public’;
if(!file_exists($path)) mkdir($path);
//生成新图片名
$image = '/upload/nulimit/'.date("YmdHis").rand(1000,9999).".".$hz;
//创建图片的实例
$dst = imagecreatefromstring(file_get_contents($dst_path));
$src = imagecreatefromstring(file_get_contents($src_path));
//获取水印图片的宽高
$src_w =$filets['width'];$src_h=$filets['height'];
list($src_w,$src_h) = getimagesize($src_path);
//如果水印图片本身带透明色,则使用imagecopy方法
imagecopy($dst, $src, $filets['x'],$filets['y'], 0, 0, $src_w, $src_h);
// imagecopymerge($dst, $src, 200,380, 0, 0, 160, 60,100);
//输出图片
list($src_w, $src_h, $dst_type) = getimagesize($dst_path);
switch ($dst_type) {
case 1://GIF
imagegif($dst, $path.$image);
break;
case 2://JPG
imagejpeg($dst, $path.$image);
break;
case 3://PNG
header('Content-Type: image/png');
imagepng($dst, $path.$image);
break;
default:
break;
}
return $image;
}