imagick.php 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <?php
  2. /**
  3. * ImageMagick 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::IMAGICK;
  17. $options->scale = 20;
  18. $options->outputBase64 = false;
  19. $options->bgColor = '#ccccaa';
  20. $options->imageTransparent = true;
  21. #$options->transparencyColor = '#ECF9BE';
  22. $options->drawLightModules = true;
  23. $options->drawCircularModules = 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 => '#A71111', // dark (true)
  33. QRMatrix::M_FINDER_DOT => '#A71111', // finder dot, dark (true)
  34. QRMatrix::M_FINDER => '#FFBFBF', // light (false)
  35. // alignment
  36. QRMatrix::M_ALIGNMENT_DARK => '#A70364',
  37. QRMatrix::M_ALIGNMENT => '#FFC9C9',
  38. // timing
  39. QRMatrix::M_TIMING_DARK => '#98005D',
  40. QRMatrix::M_TIMING => '#FFB8E9',
  41. // format
  42. QRMatrix::M_FORMAT_DARK => '#003804',
  43. QRMatrix::M_FORMAT => '#CCFB12',
  44. // version
  45. QRMatrix::M_VERSION_DARK => '#650098',
  46. QRMatrix::M_VERSION => '#E0B8FF',
  47. // data
  48. QRMatrix::M_DATA_DARK => '#4A6000',
  49. QRMatrix::M_DATA => '#ECF9BE',
  50. // darkmodule
  51. QRMatrix::M_DARKMODULE => '#080063',
  52. // separator
  53. QRMatrix::M_SEPARATOR => '#DDDDDD',
  54. // quietzone
  55. QRMatrix::M_QUIETZONE => '#DDDDDD',
  56. ];
  57. $out = (new QRCode($options))->render('https://www.youtube.com/watch?v=dQw4w9WgXcQ');
  58. header('Content-type: image/png');
  59. echo $out;
  60. exit;