imagick.php 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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::IMAGICK,
  16. 'eccLevel' => EccLevel::L,
  17. 'bgColor' => '#cccccc', // overrides the imageTransparent setting
  18. 'imageTransparent' => true,
  19. 'scale' => 20,
  20. 'drawLightModules' => true,
  21. 'drawCircularModules' => true,
  22. 'circleRadius' => 0.4,
  23. 'keepAsSquare' => [
  24. (QRMatrix::M_FINDER|QRMatrix::IS_DARK),
  25. QRMatrix::M_FINDER_DOT,
  26. (QRMatrix::M_ALIGNMENT|QRMatrix::IS_DARK),
  27. ],
  28. 'moduleValues' => [
  29. // finder
  30. (QRMatrix::M_FINDER | QRMatrix::IS_DARK) => '#A71111', // dark (true)
  31. QRMatrix::M_FINDER => '#FFBFBF', // light (false)
  32. (QRMatrix::M_FINDER_DOT | QRMatrix::IS_DARK) => '#A71111', // finder dot, dark (true)
  33. // alignment
  34. (QRMatrix::M_ALIGNMENT | QRMatrix::IS_DARK) => '#A70364',
  35. QRMatrix::M_ALIGNMENT => '#FFC9C9',
  36. // timing
  37. (QRMatrix::M_TIMING | QRMatrix::IS_DARK) => '#98005D',
  38. QRMatrix::M_TIMING => '#FFB8E9',
  39. // format
  40. (QRMatrix::M_FORMAT | QRMatrix::IS_DARK) => '#003804',
  41. QRMatrix::M_FORMAT => '#CCFB12',
  42. // version
  43. (QRMatrix::M_VERSION | QRMatrix::IS_DARK) => '#650098',
  44. QRMatrix::M_VERSION => '#E0B8FF',
  45. // data
  46. (QRMatrix::M_DATA | QRMatrix::IS_DARK) => '#4A6000',
  47. QRMatrix::M_DATA => '#ECF9BE',
  48. // darkmodule
  49. (QRMatrix::M_DARKMODULE | QRMatrix::IS_DARK) => '#080063',
  50. // separator
  51. QRMatrix::M_SEPARATOR => '#DDDDDD',
  52. // quietzone
  53. QRMatrix::M_QUIETZONE => '#DDDDDD',
  54. ],
  55. ]);
  56. header('Content-type: image/png');
  57. echo (new QRCode($options))->render('https://www.youtube.com/watch?v=dQw4w9WgXcQ');
  58. exit;