imageWithText.php 845 B

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