imageWithText.php 880 B

123456789101112131415161718192021222324252627282930313233343536
  1. <?php
  2. /**
  3. * example for additional text
  4. * @link https://github.com/chillerlan/php-qrcode/issues/35
  5. *
  6. * @filesource imageWithText.php
  7. * @created 22.06.2019
  8. * @author Smiley <smiley@chillerlan.net>
  9. * @copyright 2019 Smiley
  10. * @license MIT
  11. */
  12. namespace chillerlan\QRCodeExamples;
  13. use chillerlan\QRCode\{QRCode, QROptions};
  14. require_once __DIR__.'/../vendor/autoload.php';
  15. $data = 'https://www.youtube.com/watch?v=DLzxrzFCyOs&t=43s';
  16. $options = new QROptions([
  17. 'version' => 7,
  18. 'outputType' => QRCode::OUTPUT_IMAGE_PNG,
  19. 'scale' => 3,
  20. 'imageBase64' => false,
  21. ]);
  22. $qrcode = new QRCode($options);
  23. $qrcode->addByteSegment($data);
  24. header('Content-type: image/png');
  25. $qrOutputInterface = new QRImageWithText($options, $qrcode->getMatrix());
  26. // dump the output, with additional text
  27. echo $qrOutputInterface->dump(null, 'example text');