# 图片合并 > 生成二维码图片并与背景图合并 ``` /** * 宣传图片+二维码 * * @param string $url * @return void */ public function get_qrcode($url='') { header('Content-type: image/jpeg'); if (!file_exists('static/tmp/')) { mkdir('static/tmp/'); } $src = 'static/tmp/'.time().rand(1,999).'.png'; QRcode::png($url, $src, 'L', 9, 2); //原始图像 $dst = "static/image/qrcode_bg.jpg"; //得到原始图片信息 $dst_im = imagecreatefromjpeg($dst); $src_im = imagecreatefrompng($src); $src_info = getimagesize($src); unlink($src); //水印透明度 $alpha = 90; //合并水印图片 imagecopymerge($dst_im,$src_im,260,1000,0,0,$src_info[0],$src_info[1],$alpha); //输出合并后水印图片 imagejpeg($dst_im); imagedestroy($dst_im); imagedestroy($src_im); exit; } ```