$qrcode_size=350;
//生成二维码并加水印
QrCode::format('png')->size($qrcode_size)->margin(0)->errorCorrection("H")->merge('/storage/logo/logo3.png',
.25)->generate($url,$img_path);
$qrcode_img=imagecreatefrompng($img_path);
//
//画布宽
$width=540;
//画布高
$height=600;
//创建画布
$im=imagecreatetruecolor($width,$height);
//背景颜色
$bg=imagecolorallocate($im,255,255,255);
//字体颜色
$text_color=imagecolorallocate($im,0,0,0);
//填充背景色 1图片 2起始X轴 3起始Y轴 4结束X轴 5结束Y轴 6颜色
imagefilledrectangle($im,0,0,$width,$height,$bg);
//引入字体
$font=storage_path('font/STXIHEI.TTF');
$font_size=20;//像素字体
//要插入的标日
$title='扫码缴物业费';
//获取文字居中的x轴位置
$text_x=CommonController::CenteredWidth($width,$font_size,$font,$title);
//添加标题
imagettftext($im,$font_size,0,$text_x,60,$text_color,$font,$title);
imagecopyresampled($im,$qrcode_img, ($width-$qrcode_size)/2,100,0,0,imagesx($qrcode_img),imagesy($qrcode_img),imagesx($qrcode_img),imagesy($qrcode_img));
unlink($img_path);
ImageJPEG($im);
imagedestroy($im);
网友评论