function create_qrcode_author($out_file,$qrcode_url,$author){
if(!file_exists($qrcode_url)){
$url = 'http://'.$_SERVER['HTTP_HOST'];;
require(APP_PATH . 'Common/Common/phpqrcode/phpqrcode.php');
$errorCorrectionLevel = 'H';
$matrixPointSize = 10;
\QRcode::png($url, $qrcode_url, $errorCorrectionLevel, $matrixPointSize, 2);
}
$im_bg = @imagecreatefrompng($qrcode_url);
$QR = imagecreatefromstring(file_get_contents($qrcode_url));
$logo = imagecreatefromstring(file_get_contents($author));
$QR_width = imagesx($QR);//二维码图片宽度
$QR_height = imagesy($QR);
$logo_width = imagesx($logo);//logo图片宽度
$logo_height = imagesy($logo);//logo图片高度
$newewm = imagecreatetruecolor($QR_width, $QR_height);
$logo_qr_width = $QR_width /5;
$scale = $logo_width/$logo_qr_width;
$logo_qr_height = $logo_height/$scale;
$from_width = ($QR_width - $logo_qr_width) / 2;
//重新组合图片并调整大小
imagecopyresampled($newewm, $im_bg, 0, 0, 0, 0, $QR_width,$QR_height, $QR_width, $QR_height);
imagecopyresized($newewm, $logo, $from_width, $from_width, 0, 0, $logo_qr_width, $logo_qr_height, $logo_width, $logo_height);
//输出图片
imagejpeg ($newewm , $out_file);
imagedestroy ($newewm);
}
PS:https://blog.csdn.net/u012767761/article/details/74539779?utm_source=blogxgwz7