public function qr_br_img(){
if(!empty($this->request->get['friendcode'])){
$token=$this->request->get['friendcode'];
$tokennum=trim(substr($token,32));
}else{
$token='';
$tokennum='';
}
if(!empty($this->request->get['name'])){
$name=$this->request->get['name'];
}else{
$name='';
}
if(!empty($this->request->get['phone'])){
$phone=$this->request->get['phone'];
}else{
$phone='';
}
if(!empty($this->request->get['vipcard'])){
$vipcard=$this->request->get['vipcard'];
}else{
$vipcard='';
}
//图片水印
$mark_filename = 'https://txh.eeeeasy.com/index.php?route=txh/person/shepima&token=6666666666666666666666666666666688';
$info = getimagesize($mark_filename);
//获取图片的后缀
$type = image_type_to_extension($info[2], false);
//拼接图片资源句柄函数
$func = 'imagecreatefrom'.$type;
//创建图片资源句柄
$image = $func($mark_filename);
//裁剪图片的大小为原图的4分之一
$w = $info[0]/2;
$h = $info[1]/2;
$mark_image = imagecreatetruecolor($w, $h);
//裁剪
imagecopyresampled($mark_image, $image, 0, 0, 0, 0, $w, $h,
$info[0], $info[1]);
//销毁内存
imagedestroy($image);
//需要加水印的图片
$filename = $_SERVER['DOCUMENT_ROOT'].'/bg.png';
$mark = getimagesize($filename);
$mark_type = image_type_to_extension($mark[2], false);
//创建图片资源句柄
$mark_func = 'imagecreatefrom'.$mark_type;
$image = $mark_func($filename);
//合并,添加水印图片
imagecopymerge($image, $mark_image, 20, 30, 0,0, $w, $h, 00);
//销毁内存
imagedestroy($mark_image);
//文字水印
$font = $_SERVER['DOCUMENT_ROOT']."/msyh.ttf";
$content = $name."\n手機號碼:".$phone."\n會卡號:".$vipcard."\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n 我的二維碼";
$col = imagecolorallocatealpha($image, 0, 0, 0, 0);
//imagettftext介绍:(第一个参数:画布,第二个参数:字体大小,第三个参数:字型的角度,0为水平,第四个参数:X坐标,第五个参数:Y坐标,第六个参数:字体颜色,第七个参数:字体,第八个:文字内容
imagettftext($image, 10, 0, 20, 75, $col, $font, $content);
//图片输出函数拼接
$outFunc = 'image'.$type;
// echo 'uploading/qr_br_img/img'.$tokennum.'.'.$type;exit;
//保存图片
$outFunc($image, 'uploadimg/qr_br_img/img'.$tokennum.'.'.$type);
// imagejpeg($image,'1.jpg');
//输出到浏览器
// header("Content-Type:".$info['mime']);
// $outFunc($image);
//輸出條形碼二維碼
$bigImgPath = 'uploadimg/qr_br_img/img'.$tokennum.'.'.$type;
$qCodePath = 'https://txh.eeeeasy.com/index.php?route=txh/person/shepima&token='.$token;
$qCodePath2 = 'https://txh.eeeeasy.com/index.php?route=txh/person/shepitiao&token='.$token;
$bigImg = imagecreatefromstring(file_get_contents($bigImgPath));
$qCodeImg = imagecreatefromstring(file_get_contents($qCodePath));
$qCodeImg2 = imagecreatefromstring(file_get_contents($qCodePath2));
/* */
$qCodeImg2 = imagecreatefromstring(file_get_contents($qCodePath2));
/* */
list($qCodeWidth, $qCodeHight, $qCodeType) = getimagesize($qCodePath);
imagecopymerge($bigImg, $qCodeImg, 100, 260, 0, 0, $qCodeWidth, $qCodeHight, 100);
list($qCodeWidth, $qCodeHight, $qCodeType) = getimagesize($qCodePath2);
// imagecopymerge使用注解
imagecopymerge($bigImg, $qCodeImg2, 10, 135, 0, 0, $qCodeWidth, $qCodeHight, 100);
list($bigWidth, $bigHight, $bigType) = getimagesize($bigImgPath);
switch ($bigType) {
case 1: //gif
header('Content-Type:image/gif');
imagegif($bigImg);
break;
case 2: //jpg
header('Content-Type:image/jpg');
imagejpeg($bigImg);
break;
case 3: //jpg
header('Content-Type:image/png');
imagepng($bigImg);
break;
default:
# code...
break;
}
imagedestroy($bigImg);
imagedestroy($qcodeImg);
}
phpGD 合成图片+文字
©著作权归作者所有,转载或内容合作请联系作者
- 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
- 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
- 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
推荐阅读更多精彩内容
- 源站:http://fengyuanchen.github.io/viewer/ 应用: html: 源码上是正常...
- <?php /** * 图片水印 * @param string $source_img 原始图片url * @p...