imageWithLogo.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. /**
  3. * @created 18.11.2020
  4. * @author smiley <smiley@chillerlan.net>
  5. * @copyright 2020 smiley
  6. * @license MIT
  7. */
  8. namespace chillerlan\QRCodeExamples;
  9. use chillerlan\QRCode\{QRCode, QROptions};
  10. use chillerlan\QRCode\Common\EccLevel;
  11. use chillerlan\QRCode\Data\QRMatrix;
  12. require_once __DIR__.'/../vendor/autoload.php';
  13. $data = 'https://github.com';
  14. $options = new QROptions([
  15. 'version' => 5,
  16. 'eccLevel' => EccLevel::H,
  17. 'imageBase64' => false,
  18. 'addLogoSpace' => true,
  19. 'logoSpaceWidth' => 13,
  20. 'logoSpaceHeight' => 13,
  21. 'scale' => 6,
  22. 'imageTransparent' => false,
  23. 'drawCircularModules' => true,
  24. 'circleRadius' => 0.45,
  25. 'keepAsSquare' => [QRMatrix::M_FINDER, QRMatrix::M_FINDER_DOT],
  26. ]);
  27. $qrcode = new QRCode($options);
  28. $qrcode->addByteSegment($data);
  29. header('Content-type: image/png');
  30. $qrOutputInterface = new QRImageWithLogo($options, $qrcode->getMatrix());
  31. // dump the output, with an additional logo
  32. echo $qrOutputInterface->dump(null, __DIR__.'/octocat.png');