imageWithLogo.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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. /**
  14. * @property int $logoSpaceWidth
  15. * @property int $logoSpaceHeight
  16. *
  17. * @noinspection PhpIllegalPsrClassPathInspection
  18. */
  19. class LogoOptions extends QROptions{
  20. // size in QR modules, multiply with QROptions::$scale for pixel size
  21. protected int $logoSpaceWidth;
  22. protected int $logoSpaceHeight;
  23. }
  24. $options = new LogoOptions;
  25. $options->version = 7;
  26. $options->eccLevel = EccLevel::H;
  27. $options->imageBase64 = false;
  28. $options->logoSpaceWidth = 13;
  29. $options->logoSpaceWidth = 13;
  30. $options->scale = 5;
  31. $options->imageTransparent = false;
  32. $qrcode = new QRCode($options);
  33. $qrcode->addByteSegment($data);
  34. header('Content-type: image/png');
  35. $qrOutputInterface = new QRImageWithLogo($options, $qrcode->getMatrix());
  36. // dump the output, with an additional logo
  37. echo $qrOutputInterface->dump(null, __DIR__.'/octocat.png');