qrcode_1.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php
  2. include "php/phpqrcode.php";
  3. $store_id=$_POST['id'];
  4. $logo = $_POST['downlogo'];//准备好的logo图片
  5. $data= $_POST['url'];
  6. $errorCorrectionLevel="L";
  7. $matrixPointSize="8";
  8. //QRcode::png($data,false,$errorCorrectionLevel,$matrixPointSize);
  9. $templogo='temp/'.$store_id.'qrcode.png';
  10. QRcode::png($data,$templogo , $errorCorrectionLevel, $matrixPointSize, 2);
  11. $QR =$templogo;//已经生成的原始二维码图
  12. if ($logo !== FALSE) {
  13. $QR = imagecreatefromstring(file_get_contents($QR));
  14. $logo = imagecreatefromstring(file_get_contents($logo));
  15. $QR_width = imagesx($QR);//二维码图片宽度
  16. $QR_height = imagesy($QR);//二维码图片高度
  17. $logo_width = imagesx($logo);//logo图片宽度
  18. $logo_height = imagesy($logo);//logo图片高度
  19. $logo_qr_width = $QR_width / 5;
  20. $scale = $logo_width/$logo_qr_width;
  21. $logo_qr_height = $logo_height/$scale;
  22. $from_width = ($QR_width - $logo_qr_width) / 2;
  23. //重新组合图片并调整大小
  24. imagecopyresampled($QR, $logo, $from_width, $from_width, 0, 0, $logo_qr_width,
  25. $logo_qr_height, $logo_width, $logo_height);
  26. }
  27. //输出图片
  28. $templogonew= 'temp/'.$store_id.'.png';
  29. imagepng($QR,$templogonew);
  30. echo '<img src='.$templogonew.'>';
  31. ?>