美文网首页
php生成二维码+合并活动图片

php生成二维码+合并活动图片

作者: 风度翩翩的程序猿 | 来源:发表于2021-08-26 13:19 被阅读0次
     $errorCorrectionLevel = 'L';    //容错级别
            $matrixPointSize = 5;           //生成图片大小
            //生成二维码图片
            $url = $this->user_id ;
            $filename = $this->fileName();
            QRcode::png($url, $filename, $errorCorrectionLevel, $matrixPointSize, 2);
            
            $x = 420;
            $y = 660;
            //合成带logo的二维码图片跟 模板图片--------------start
            $path_1 = './upload/haibao.png';
            $path_2 = base_url() . $filename;
            $image_1 = imagecreatefrompng($path_1);
            $image_2 = imagecreatefrompng($path_2);
            $image_3 = imageCreatetruecolor(imagesx($image_1), imagesy($image_1));
            $color = imagecolorallocate($image_3, 255, 255, 255);
            imagefill($image_3, 0, 0, $color);
            imageColorTransparent($image_3, $color);
            imagecopyresampled($image_3, $image_1, 0, 0, 0, 0, imagesx($image_1), imagesy($image_1), imagesx($image_1), imagesy($image_1));
    
            imagecopymerge($image_3, $image_2, $x, $y, 0, 0, imagesx($image_2), imagesy($image_2), 100);
            //合成带logo的二维码图片跟 模板图片--------------end
    
            //输出到本地文件夹
            $file = md5(basename($path_1));
            $EchoPath = './upload/' . $file . '.png';
            imagepng($image_3, $EchoPath);
            imagedestroy($image_3);
            //返回生成的路径
            return $this->json_data(array('st' => 1, 'data' => base_url().$EchoPath));
    

    相关文章

      网友评论

          本文标题:php生成二维码+合并活动图片

          本文链接:https://www.haomeiwen.com/subject/dmfuiltx.html