利用PHPqrcode类库生成带参数的二维码后将它和其他图片进行合成,但是需要调整二维码的大小,然后用PHP的图片处理函数将它放大了3倍,但是这时和其他图片合成后,二维码里面的参数不见了,扫码之后什么都没有,怎么解?
上代码
require 'phpqrcode/phpqrcode.php'; $data = 'http://'.$_SERVER['SERVER_NAME'].'/hoax.php/Index/result?openid='.I('get.openid'); $level = 'L'; $size = 6; $file = './Public/hoax/qrcode/qrcode.png'; $qrcode = new QRcode(); $qrcode->png($data, $file, $level, $size); // 重构二维码大小 $qrfile = imagecreatefromstring(file_get_contents($file)); $qr_percent = 3.2; list($qr_width,$qr_height) = getimagesize($file); $qr_new_width = $qr_width * $qr_percent; $qr_new_height = $qr_height * $qr_percent; $qr_src = imagecreatefrompng($file); $qr_new = imagecreatetruecolor($qr_new_width, $qr_new_height); imagecopyresized($qr_new, $qr_src, 0, 0, 0, 0, $qr_new_width, $qr_new_height, $qr_width, $qr_height); $bgimg = imagecreatefromstring(file_get_contents('./Public/hoax/img/2.png')); imagecopymerge($bgimg, $qr_new, 100, 300, 0, 0, imagesx($qr_new), imagesy($qr_new), 100); header('Content-Type:image/jpeg'); imagejpeg($bgimg); imagedestroy($bgimg);
光阴似箭催人老,日月如移越少年。