image.php 2.1 KB

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