imageWithLogo.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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. require_once __DIR__.'/../vendor/autoload.php';
  13. $data = 'https://www.youtube.com/watch?v=DLzxrzFCyOs&t=43s';
  14. /**
  15. * @property int $logoWidth
  16. * @property int $logoHeight
  17. *
  18. * @noinspection PhpIllegalPsrClassPathInspection
  19. */
  20. class LogoOptions extends QROptions{
  21. protected int $logoWidth;
  22. protected int $logoHeight;
  23. }
  24. $options = new LogoOptions;
  25. $options->version = 7;
  26. $options->eccLevel = QRCode::ECC_H;
  27. $options->imageBase64 = false;
  28. $options->logoWidth = 13;
  29. $options->logoHeight = 13;
  30. $options->scale = 5;
  31. $options->imageTransparent = false;
  32. header('Content-type: image/png');
  33. $qrOutputInterface = new QRImageWithLogo($options, (new QRCode($options))->getMatrix($data));
  34. // dump the output, with an additional logo
  35. echo $qrOutputInterface->dump(null, __DIR__.'/octocat.png');