Files
amb_wechatapp/application/common/library/Poster.php
T

48 lines
1.8 KiB
PHP

<?php
namespace app\common\library;
use think\Config;
class Poster
{
/**
* 生成宣传海报
* @param array 参数,包括图片和文字
* @param string $filename 生成海报文件名,不传此参数则不生成文件,直接输出图片
* @return [type] [description]
*/
public function createPoster($type){
//这是需要插入到背景图的图片url
// $qrodeimg = MODULE_URL."public/uploads/appcode/appcode_{$this->auth->id}.png";
//这是背景图片的url
$bannerimg = MODULE_URL."public/assets/poster/{$type}.jpg";
//用户信息
//这是要插入到图片的文字
if ($bannerimg) {
if (is_file($bannerimg)) {
//创建画布
$bgImg = imagecreatefromstring(file_get_contents($bannerimg));
// imagecopyresampled($bgImg, $head_img1, 299, 870, 0, 0, 156, 156, imagesx($head_img1), imagesy($head_img1));
// $head_img1 = imagecreatefromstring(file_get_contents($qrodeimg));
//将$qrodeimg插入到$bannerimg里
// if($i==1){
// imagecopyresampled($logo, $head_img1, 525, 865, 0, 0, 170, 170, imagesx($head_img1), imagesy($head_img1));
// }
// if($i==2){
// imagecopyresampled($logo, $head_img1, 292, 686, 0, 0, 170, 170, imagesx($head_img1), imagesy($head_img1));
// }
// if($i==3){
// imagecopyresampled($bgImg, $head_img1, 299, 870, 0, 0, 156, 156, imagesx($head_img1), imagesy($head_img1));
// }
//生成图片
imagepng($bgImg, ROOT_PATH."public/uploads/poster/poster_{$type}.png");
}
return true;//返回结果图片url
} else {
return false;
}
}
}