imageWithLogo.php 1.1 KB

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