imageWithLogo.php 1.2 KB

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