image.php 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?php
  2. /**
  3. *
  4. * @filesource image.php
  5. * @created 24.12.2017
  6. * @author Smiley <smiley@chillerlan.net>
  7. * @copyright 2017 Smiley
  8. * @license MIT
  9. */
  10. namespace chillerlan\QRCodeExamples;
  11. use chillerlan\QRCode\{QRCode, QROptions};
  12. use chillerlan\QRCode\Data\QRMatrix;
  13. use chillerlan\QRCode\Common\EccLevel;
  14. require_once __DIR__.'/../vendor/autoload.php';
  15. $data = 'https://www.youtube.com/watch?v=DLzxrzFCyOs&t=43s';
  16. $options = new QROptions([
  17. 'version' => 5,
  18. 'outputType' => QRCode::OUTPUT_IMAGE_PNG,
  19. 'eccLevel' => EccLevel::L,
  20. 'scale' => 5,
  21. 'imageBase64' => false,
  22. 'moduleValues' => [
  23. // finder
  24. QRMatrix::M_FINDER | QRMatrix::IS_DARK => [0, 63, 255], // dark (true)
  25. QRMatrix::M_FINDER => [255, 255, 255], // light (false), white is the transparency color and is enabled by default
  26. QRMatrix::M_FINDER_DOT | QRMatrix::IS_DARK => [241, 28, 163], // finder dot, dark (true)
  27. // alignment
  28. QRMatrix::M_ALIGNMENT | QRMatrix::IS_DARK => [255, 0, 255],
  29. QRMatrix::M_ALIGNMENT => [255, 255, 255],
  30. // timing
  31. QRMatrix::M_TIMING | QRMatrix::IS_DARK => [255, 0, 0],
  32. QRMatrix::M_TIMING => [255, 255, 255],
  33. // format
  34. QRMatrix::M_FORMAT | QRMatrix::IS_DARK => [67, 99, 84],
  35. QRMatrix::M_FORMAT => [255, 255, 255],
  36. // version
  37. QRMatrix::M_VERSION | QRMatrix::IS_DARK => [62, 174, 190],
  38. QRMatrix::M_VERSION => [255, 255, 255],
  39. // data
  40. QRMatrix::M_DATA | QRMatrix::IS_DARK => [0, 0, 0],
  41. QRMatrix::M_DATA => [255, 255, 255],
  42. // darkmodule
  43. QRMatrix::M_DARKMODULE | QRMatrix::IS_DARK => [0, 0, 0],
  44. // separator
  45. QRMatrix::M_SEPARATOR => [255, 255, 255],
  46. // quietzone
  47. QRMatrix::M_QUIETZONE => [255, 255, 255],
  48. // logo (requires a call to QRMatrix::setLogoSpace()), see QRImageWithLogo
  49. QRMatrix::M_LOGO => [255, 255, 255],
  50. ],
  51. ]);
  52. header('Content-type: image/png');
  53. echo (new QRCode($options))->render($data);