<?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再放到繪製的圖片上,僅多了對複製圖片的縮放操作
*/
}