imagick.php 2.0 KB

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