image.php 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <?php
  2. /**
  3. * GdImage output example
  4. *
  5. * @created 24.12.2017
  6. * @author Smiley <smiley@chillerlan.net>
  7. * @copyright 2017 Smiley
  8. * @license MIT
  9. */
  10. use chillerlan\QRCode\{QRCode, QROptions};
  11. use chillerlan\QRCode\Data\QRMatrix;
  12. use chillerlan\QRCode\Output\QROutputInterface;
  13. require_once __DIR__.'/../vendor/autoload.php';
  14. $options = new QROptions;
  15. $options->version = 7;
  16. $options->outputType = QROutputInterface::GDIMAGE_PNG;
  17. $options->scale = 20;
  18. $options->outputBase64 = false;
  19. $options->bgColor = [200, 150, 200];
  20. $options->imageTransparent = true;
  21. #$options->transparencyColor = [233, 233, 233];
  22. $options->drawCircularModules = true;
  23. $options->drawLightModules = true;
  24. $options->circleRadius = 0.4;
  25. $options->keepAsSquare = [
  26. QRMatrix::M_FINDER_DARK,
  27. QRMatrix::M_FINDER_DOT,
  28. QRMatrix::M_ALIGNMENT_DARK,
  29. ];
  30. $options->moduleValues = [
  31. // finder
  32. QRMatrix::M_FINDER_DARK => [0, 63, 255], // dark (true)
  33. QRMatrix::M_FINDER_DOT => [0, 63, 255], // finder dot, dark (true)
  34. QRMatrix::M_FINDER => [233, 233, 233], // light (false), white is the transparency color and is enabled by default
  35. // alignment
  36. QRMatrix::M_ALIGNMENT_DARK => [255, 0, 255],
  37. QRMatrix::M_ALIGNMENT => [233, 233, 233],
  38. // timing
  39. QRMatrix::M_TIMING_DARK => [255, 0, 0],
  40. QRMatrix::M_TIMING => [233, 233, 233],
  41. // format
  42. QRMatrix::M_FORMAT_DARK => [67, 159, 84],
  43. QRMatrix::M_FORMAT => [233, 233, 233],
  44. // version
  45. QRMatrix::M_VERSION_DARK => [62, 174, 190],
  46. QRMatrix::M_VERSION => [233, 233, 233],
  47. // data
  48. QRMatrix::M_DATA_DARK => [0, 0, 0],
  49. QRMatrix::M_DATA => [233, 233, 233],
  50. // darkmodule
  51. QRMatrix::M_DARKMODULE => [0, 0, 0],
  52. // separator
  53. QRMatrix::M_SEPARATOR => [233, 233, 233],
  54. // quietzone
  55. QRMatrix::M_QUIETZONE => [233, 233, 233],
  56. // logo (requires a call to QRMatrix::setLogoSpace()), see QRImageWithLogo
  57. QRMatrix::M_LOGO => [233, 233, 233],
  58. ];
  59. $out = (new QRCode($options))->render('https://www.youtube.com/watch?v=dQw4w9WgXcQ');
  60. header('Content-type: image/png');
  61. echo $out;
  62. exit;