标签:拷贝 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); }
标签:拷贝 sam php com images contents des 二维 技术
原文地址:https://www.cnblogs.com/akidongzi/p/10534455.html