Home >Backend Development >PHP Tutorial >PHP QR Code barcode and QR code generation class library

PHP QR Code barcode and QR code generation class library

WBOY
WBOYOriginal
2016-07-25 08:42:181428browse
//生成带logo的二维码图片
  1. include 'phpqrcode.php';
  2. $value = 'http://www.cnblogs.com/txw1958/'; //QR code content
  3. $errorCorrectionLevel = 'L';/ /Error tolerance level
  4. $matrixPointSize = 6; //Generate image size
  5. //Generate QR code image
  6. QRcode::png($value, 'qrcode.png', $errorCorrectionLevel, $matrixPointSize, 2);
  7. $logo = 'logo.png';//Prepared logo image
  8. $QR = 'qrcode.png';//Generated original QR code image
  9. if ($logo !== FALSE) {
  10. $QR = imagecreatefromstring (file_get_contents($QR));
  11. $logo = imagecreatefromstring(file_get_contents($logo));
  12. $QR_width = imagesx($QR);//QR code image width
  13. $QR_height = imagesy($QR);// QR code image height
  14. $logo_width = imagesx($logo);//logo image width
  15. $logo_height = imagesy($logo);//logo image height
  16. $logo_qr_width = $QR_width / 5;
  17. $scale = $logo_width /$logo_qr_width;
  18. $logo_qr_height = $logo_height/$scale;
  19. $from_width = ($QR_width - $logo_qr_width) / 2;
  20. //Recombine the image and resize
  21. imagecopyresampled($QR, $logo, $from_width, $ from_width, 0, 0, $logo_qr_width,
  22. $logo_qr_height, $logo_width, $logo_height);
  23. }
  24. //Output image
  25. imagepng($QR, 'helloweixin.png');
  26. echo '';
Copy code

Class library, PHP


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:PHP Web Trojan ScannerNext article:PHP Web Trojan Scanner