<?php
public function Synthesis(){
// $bigImgPath = "./00.jpg";
// $qCodePath = "./2.jpg";
// $bigImg = imagecreatefromstring(file_get_contents($bigImgPath));
// $qCodeImg = imagecreatefromstring(file_get_contents($qCodePath));
// list($qCodeWidth, $qCodeHight, $qCodeType) = getimagesize($qCodePath);
// imagecopymerge($bigImg, $qCodeImg, 239, 677, 0, 0, $qCodeWidth, $qCodeHight, 100);
// list($bigWidth, $bigHight, $bigType) = getimagesize($bigImgPath);
// imagejpeg($bigImg,'./images/3.jpg');
$Absolute_Path=substr($_SERVER['SCRIPT_FILENAME'],0,-10);
//本地的绝对路径
$dst_path = '00.jpg';//背景图
$src_path= '2.jpg'; //头像
$hz = substr(strrchr($dst_path, '.'), 1);
$path = $Absolute_Path.'/';
//生成新图片名
$image = $path.date("YmdHis").rand(1000,9999).".".$hz;
//创建图片的实例
$dst = imagecreatefromstring(file_get_contents($dst_path));
$src = imagecreatefromstring(file_get_contents($src_path));
//获取水印图片的宽高
$src_w =139;$src_h=58;
list($src_w,$src_h) = getimagesize($src_path);
//如果水印图片本身带透明色,则使用imagecopy方法
imagecopy($dst, $src, 150,300, 0, 0, $src_w, $src_h);
//输出图片
list($src_w, $src_h, $dst_type) = getimagesize($dst_path);
// var_dump($dst);
// var_dump($image);die;
switch ($dst_type) {
case 1://GIF
imagegif($dst, $image);
break;
case 2://JPG
imagejpeg($dst, $image);
break;
case 3://PNG
// header('Content-Type: image/png');
imagepng($dst, $image);
break;
default:
break;
}
return $image;
/*
补充:
imagecopy($im, $head_img, 0, 0, 0, 0, 1920, 680);//复制定义的图片到白色图片上,前两个0分别是复制图片的X轴,Y轴,起点是左上角。后两个0是放置位置的X轴和Y轴,最后1920*680是复制图片的大小
imagecopyresized($im, $bg_img, 40, 490, 0, 0, 150, 150, 1920, 680);//与上一个函数的区别在于,此函数可以从小调整复制图片的大小,不同的位置就是两个150,代表将1920*680的图片 缩小成150*150再放到绘制的图片上,仅多了对复制图片的缩放操作
*/
}