imageWithText.php 797 B

12345678910111213141516171819202122232425262728293031
  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. 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. header('Content-type: image/png');
  22. $qrOutputInterface = new QRImageWithText($options, (new QRCode($options))->getMatrix($data));
  23. // dump the output, with additional text
  24. echo $qrOutputInterface->dump(null, 'example text');