ThinkPHP3.2 生成带背景图用户信息二维码



png($url,$path,$level,$size);

        //给生成的二维码添加背景图(方法二)
        $bigImgPath = './Public/4.png';
        $qCodePath = $path;
        $bigImg = imagecreatefromstring(file_get_contents($bigImgPath));
        $qCodeImg = imagecreatefromstring(file_get_contents($qCodePath));
        list($qCodeWidth, $qCodeHight, $qCodeType) = getimagesize($qCodePath);
        // imagecopymerge使用注解
        imagecopymerge($bigImg, $qCodeImg, 255, 875, 0, 0, $qCodeWidth, $qCodeHight, 100);
        // list($bigWidth, $bigHight, $bigType) = getimagesize($bigImgPath);
        list($bigWidth, $bigHight) = getimagesize($bigImgPath);
        $usermobile = "崔五月你好啊";
        $yourname = $usermobile; 
        $red = imagecolorallocate($bigImg, 241,215, 60);
        imagefttext($bigImg, 30, 0, 310, 728, $red, './MSYHBD.TTF', $yourname);
        header('Content-Type:image/png');
        $savepath="./Public/Uploads/".time().mt_rand(111,999).".png"; //推广二维码本地存储路径
        imagepng($bigImg,$savepath);//推广二维码存到本地
        $this->assign("usermobile",$usermobile);
        echo $savepath;//最终路径
        // $this->display();
    }
}


你可能感兴趣的:(PHP)