imageWithLogo.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. /**
  3. *
  4. * @filesource imageWithLogo.php
  5. * @created 18.11.2020
  6. * @author smiley <smiley@chillerlan.net>
  7. * @copyright 2020 smiley
  8. * @license MIT
  9. */
  10. namespace chillerlan\QRCodeExamples;
  11. use chillerlan\QRCode\{QRCode, QROptions};
  12. use chillerlan\QRCode\Common\EccLevel;
  13. require_once __DIR__.'/../vendor/autoload.php';
  14. $data = 'https://www.youtube.com/watch?v=DLzxrzFCyOs&t=43s';
  15. /**
  16. * @property int $logoSpaceWidth
  17. * @property int $logoSpaceHeight
  18. *
  19. * @noinspection PhpIllegalPsrClassPathInspection
  20. */
  21. class LogoOptions extends QROptions{
  22. protected int $logoSpaceWidth;
  23. protected int $logoSpaceHeight;
  24. }
  25. $options = new LogoOptions;
  26. $options->version = 7;
  27. $options->eccLevel = EccLevel::H;
  28. $options->imageBase64 = false;
  29. $options->logoSpaceWidth = 13;
  30. $options->logoSpaceHeight = 13;
  31. $options->scale = 5;
  32. $options->imageTransparent = false;
  33. $qrcode = new QRCode($options);
  34. $qrcode->addByteSegment($data);
  35. header('Content-type: image/png');
  36. $qrOutputInterface = new QRImageWithLogo($options, $qrcode->getMatrix());
  37. // dump the output, with an additional logo
  38. echo $qrOutputInterface->dump(null, __DIR__.'/octocat.png');