image.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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;
  12. use chillerlan\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' => 5,
  17. 'outputType' => QRCode::OUTPUT_IMAGE_PNG,
  18. 'eccLevel' => QRCode::ECC_L,
  19. 'scale' => 10,
  20. 'imageBase64' => false,
  21. 'moduleValues' => [
  22. // finder
  23. 1536 => [255, 0, 0], // dark (true)
  24. 6 => [255, 255, 255], // light (false), white is the transparency color and is enabled by default
  25. // alignment
  26. 2560 => [255, 0, 0],
  27. 10 => [255, 255, 255],
  28. // timing
  29. 3072 => [0, 0, 0],
  30. 12 => [200, 200, 200],
  31. // format
  32. 3584 => [0, 0, 0],
  33. 14 => [200, 200, 200],
  34. // version
  35. 4096 => [0, 0, 0],
  36. 16 => [200, 200, 200],
  37. // data
  38. 1024 => [0, 0, 150],
  39. 4 => [255, 255, 255],
  40. // darkmodule
  41. 512 => [0, 0, 0],
  42. // separator
  43. 8 => [200, 200, 200],
  44. // quietzone
  45. 18 => [255, 255, 255],
  46. ],
  47. ]);
  48. header('Content-type: image/png');
  49. echo (new QRCode($options))->render($data);