image.php 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. <?php
  2. /**
  3. * @created 24.12.2017
  4. * @author Smiley <smiley@chillerlan.net>
  5. * @copyright 2017 Smiley
  6. * @license MIT
  7. */
  8. use chillerlan\QRCode\{QRCode, QROptions};
  9. use chillerlan\QRCode\Common\EccLevel;
  10. use chillerlan\QRCode\Data\QRMatrix;
  11. use chillerlan\QRCode\Output\QROutputInterface;
  12. require_once __DIR__.'/../vendor/autoload.php';
  13. $options = new QROptions([
  14. 'version' => 7,
  15. 'outputType' => QROutputInterface::GDIMAGE_PNG,
  16. 'eccLevel' => EccLevel::L,
  17. 'scale' => 20,
  18. 'imageBase64' => false,
  19. 'bgColor' => [200, 150, 200],
  20. 'imageTransparent' => true,
  21. # 'transparencyColor' => [233, 233, 233],
  22. 'drawCircularModules' => true,
  23. 'drawLightModules' => true,
  24. 'circleRadius' => 0.4,
  25. 'keepAsSquare' => [
  26. QRMatrix::M_FINDER_DARK,
  27. QRMatrix::M_FINDER_DOT,
  28. QRMatrix::M_ALIGNMENT_DARK,
  29. ],
  30. '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. ]);
  60. try{
  61. $im = (new QRCode($options))->render('https://www.youtube.com/watch?v=dQw4w9WgXcQ');
  62. }
  63. catch(Throwable $e){
  64. exit($e->getMessage());
  65. }
  66. header('Content-type: image/png');
  67. echo $im;
  68. exit;