码迷,mamicode.com
首页 > Web开发 > 详细

PHP生成圆角二维码logo

时间:2019-03-15 01:11:53      阅读:408      评论:0      收藏:0      [点我收藏+]

标签:拷贝   sam   php   com   images   contents   des   二维   技术   

PHP生成圆角二维码logo

 

技术图片

 

function cornerimg($filename, $cornerimg, $logoimg, $centerbigger=5){
    //获取二维码
    $qrcode = file_get_contents($filename);
    $qrcode = imagecreatefromstring($qrcode);
    $qrcode_width = imagesx($qrcode);
    $qrcode_height = imagesy($qrcode);

//圆角图片
    $corner = file_get_contents($cornerimg);
    $corner = imagecreatefromstring($corner);
    $corner_width = imagesx($corner);
    $corner_height = imagesy($corner);

//计算圆角图片的宽高及相对于二维码的摆放位置,将圆角图片拷贝到二维码中央
    $corner_qr_height = $corner_qr_width = $qrcode_width/$centerbigger;
    $from_width = ($qrcode_width-$corner_qr_width)/2;
    imagecopyresampled($qrcode, $corner, $from_width, $from_width, 0, 0, $corner_qr_width, $corner_qr_height, $corner_width, $corner_height);


//logo图片
    $logo = file_get_contents($logoimg);
    $logo = imagecreatefromstring($logo);
    $logo_width = imagesx($logo);
    $logo_height = imagesy($logo);


//计算logo图片的宽高及相对于二维码的摆放位置,将logo拷贝到二维码中央
    $logo_qr_height = $logo_qr_width = $qrcode_width/$centerbigger - 6;
    $from_width = ($qrcode_width-$logo_qr_width)/2;
    imagecopyresampled($qrcode, $logo, $from_width, $from_width, 0, 0, $logo_qr_width, $logo_qr_height, $logo_width, $logo_height);


    header(‘Content-type: image/png‘);
    imagepng($qrcode);
    imagedestroy($qrcode);
    imagedestroy($corner);
    imagedestroy($logo);
}

 

PHP生成圆角二维码logo

标签:拷贝   sam   php   com   images   contents   des   二维   技术   

原文地址:https://www.cnblogs.com/akidongzi/p/10534455.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!