imageWithLogo.php 917 B

12345678910111213141516171819202122232425262728293031323334353637
  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. require_once __DIR__.'/../vendor/autoload.php';
  12. $data = 'https://www.youtube.com/watch?v=DLzxrzFCyOs&t=43s';
  13. $options = new QROptions([
  14. 'version' => 7,
  15. 'eccLevel' => EccLevel::H,
  16. 'imageBase64' => false,
  17. 'addLogoSpace' => true,
  18. 'logoSpaceWidth' => 13,
  19. 'logoSpaceHeight' => 13,
  20. 'scale' => 5,
  21. 'imageTransparent' => false,
  22. ]);
  23. $qrcode = new QRCode($options);
  24. $qrcode->addByteSegment($data);
  25. header('Content-type: image/png');
  26. $qrOutputInterface = new QRImageWithLogo($options, $qrcode->getMatrix());
  27. // dump the output, with an additional logo
  28. echo $qrOutputInterface->dump(null, __DIR__.'/octocat.png');