imagick.php 2.0 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. namespace chillerlan\QRCodeExamples;
  9. use chillerlan\QRCode\{QRCode, QROptions};
  10. use chillerlan\QRCode\Data\QRMatrix;
  11. use chillerlan\QRCode\Common\EccLevel;
  12. require_once __DIR__.'/../vendor/autoload.php';
  13. $data = 'https://www.youtube.com/watch?v=dQw4w9WgXcQ';
  14. $options = new QROptions([
  15. 'version' => 7,
  16. 'outputType' => QRCode::OUTPUT_IMAGICK,
  17. 'eccLevel' => EccLevel::L,
  18. 'imagickBG' => '#FFFFFF',
  19. 'scale' => 20,
  20. 'drawCircularModules' => true,
  21. 'circleRadius' => 0.4,
  22. 'keepAsSquare' => [QRMatrix::M_FINDER|QRMatrix::IS_DARK, QRMatrix::M_FINDER_DOT, QRMatrix::M_ALIGNMENT|QRMatrix::IS_DARK],
  23. 'moduleValues' => [
  24. // finder
  25. QRMatrix::M_FINDER | QRMatrix::IS_DARK => '#A71111', // dark (true)
  26. QRMatrix::M_FINDER => '#FFBFBF', // light (false)
  27. QRMatrix::M_FINDER_DOT | QRMatrix::IS_DARK => '#A71111', // finder dot, dark (true)
  28. // alignment
  29. QRMatrix::M_ALIGNMENT | QRMatrix::IS_DARK => '#A70364',
  30. QRMatrix::M_ALIGNMENT => '#FFC9C9',
  31. // timing
  32. QRMatrix::M_TIMING | QRMatrix::IS_DARK => '#98005D',
  33. QRMatrix::M_TIMING => '#FFB8E9',
  34. // format
  35. QRMatrix::M_FORMAT | QRMatrix::IS_DARK => '#003804',
  36. QRMatrix::M_FORMAT => '#CCFB12',
  37. // version
  38. QRMatrix::M_VERSION | QRMatrix::IS_DARK => '#650098',
  39. QRMatrix::M_VERSION => '#E0B8FF',
  40. // data
  41. QRMatrix::M_DATA | QRMatrix::IS_DARK => '#4A6000',
  42. QRMatrix::M_DATA => '#ECF9BE',
  43. // darkmodule
  44. QRMatrix::M_DARKMODULE | QRMatrix::IS_DARK => '#080063',
  45. // separator
  46. QRMatrix::M_SEPARATOR => '#DDDDDD',
  47. // quietzone
  48. QRMatrix::M_QUIETZONE => '#DDDDDD',
  49. ],
  50. ]);
  51. header('Content-type: image/png');
  52. echo (new QRCode($options))->render($data);