eps.php 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <?php
  2. /**
  3. * @created 10.05.2022
  4. * @author Smiley <smiley@chillerlan.net>
  5. * @copyright 2022 Smiley
  6. * @license MIT
  7. */
  8. use chillerlan\QRCode\{QRCode, QROptions};
  9. use chillerlan\QRCode\Data\QRMatrix;
  10. use chillerlan\QRCode\Output\QROutputInterface;
  11. require_once __DIR__.'/../vendor/autoload.php';
  12. $options = new QROptions;
  13. $options->version = 7;
  14. $options->outputType = QROutputInterface::EPS;
  15. $options->scale = 5;
  16. $options->drawLightModules = false;
  17. $options->bgColor = [222, 222, 222];
  18. $options->moduleValues = [
  19. // finder
  20. QRMatrix::M_FINDER_DARK => [0, 63, 255], // dark (true)
  21. QRMatrix::M_FINDER_DOT => [0, 63, 255], // finder dot, dark (true)
  22. QRMatrix::M_FINDER => [233, 233, 233], // light (false)
  23. // alignment
  24. QRMatrix::M_ALIGNMENT_DARK => [255, 0, 255],
  25. QRMatrix::M_ALIGNMENT => [233, 233, 233],
  26. // timing
  27. QRMatrix::M_TIMING_DARK => [255, 0, 0],
  28. QRMatrix::M_TIMING => [233, 233, 233],
  29. // format
  30. QRMatrix::M_FORMAT_DARK => [67, 159, 84],
  31. QRMatrix::M_FORMAT => [233, 233, 233],
  32. // version
  33. QRMatrix::M_VERSION_DARK => [62, 174, 190],
  34. QRMatrix::M_VERSION => [233, 233, 233],
  35. // data
  36. QRMatrix::M_DATA_DARK => [0, 0, 0],
  37. QRMatrix::M_DATA => [233, 233, 233],
  38. // darkmodule
  39. QRMatrix::M_DARKMODULE => [0, 0, 0],
  40. // separator
  41. QRMatrix::M_SEPARATOR => [233, 233, 233],
  42. // quietzone
  43. QRMatrix::M_QUIETZONE => [233, 233, 233],
  44. // logo (requires a call to QRMatrix::setLogoSpace()), see QRImageWithLogo
  45. QRMatrix::M_LOGO => [233, 233, 233],
  46. ];
  47. if(php_sapi_name() !== 'cli'){
  48. // if viewed in the browser, we should push it as file download as EPS isn't usually supported
  49. header('Content-type: application/postscript');
  50. header('Content-Disposition: filename="qrcode.eps"');
  51. }
  52. echo (new QRCode($options))->render('https://www.youtube.com/watch?v=dQw4w9WgXcQ', __DIR__.'/test.eps');
  53. exit;