image.php 2.0 KB

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