imagick.php 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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\QRImagick;
  13. require_once __DIR__.'/../vendor/autoload.php';
  14. $options = new QROptions;
  15. $options->version = 7;
  16. $options->outputInterface = QRImagick::class;
  17. $options->imagickFormat = 'webp';
  18. $options->quality = 90;
  19. $options->scale = 20;
  20. $options->outputBase64 = false;
  21. $options->bgColor = '#ccccaa';
  22. $options->imageTransparent = true;
  23. $options->transparencyColor = '#ccccaa';
  24. $options->drawLightModules = true;
  25. $options->drawCircularModules = true;
  26. $options->circleRadius = 0.4;
  27. $options->keepAsSquare = [
  28. QRMatrix::M_FINDER_DARK,
  29. QRMatrix::M_FINDER_DOT,
  30. QRMatrix::M_ALIGNMENT_DARK,
  31. ];
  32. $options->moduleValues = [
  33. // finder
  34. QRMatrix::M_FINDER_DARK => '#A71111', // dark (true)
  35. QRMatrix::M_FINDER_DOT => '#A71111', // finder dot, dark (true)
  36. QRMatrix::M_FINDER => '#FFBFBF', // light (false)
  37. // alignment
  38. QRMatrix::M_ALIGNMENT_DARK => '#A70364',
  39. QRMatrix::M_ALIGNMENT => '#FFC9C9',
  40. // timing
  41. QRMatrix::M_TIMING_DARK => '#98005D',
  42. QRMatrix::M_TIMING => '#FFB8E9',
  43. // format
  44. QRMatrix::M_FORMAT_DARK => '#003804',
  45. QRMatrix::M_FORMAT => '#CCFB12',
  46. // version
  47. QRMatrix::M_VERSION_DARK => '#650098',
  48. QRMatrix::M_VERSION => '#E0B8FF',
  49. // data
  50. QRMatrix::M_DATA_DARK => '#4A6000',
  51. QRMatrix::M_DATA => '#ECF9BE',
  52. // darkmodule
  53. QRMatrix::M_DARKMODULE => '#080063',
  54. // separator
  55. QRMatrix::M_SEPARATOR => '#DDDDDD',
  56. // quietzone
  57. QRMatrix::M_QUIETZONE => '#DDDDDD',
  58. ];
  59. $out = (new QRCode($options))->render('https://www.youtube.com/watch?v=dQw4w9WgXcQ');
  60. header('Content-type: image/webp');
  61. echo $out;
  62. exit;