eps.php 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <?php
  2. /**
  3. * @created 10.05.2022
  4. * @author Smiley <smiley@chillerlan.net>
  5. * @copyright 2022 Smiley
  6. * @license MIT
  7. */
  8. namespace chillerlan\QRCodeExamples;
  9. use chillerlan\QRCode\{QRCode, QROptions};
  10. use chillerlan\QRCode\Common\EccLevel;
  11. use chillerlan\QRCode\Data\QRMatrix;
  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_EPS,
  17. 'eccLevel' => EccLevel::L,
  18. 'scale' => 5,
  19. 'addQuietzone' => true,
  20. 'cachefile' => __DIR__.'/test.eps',
  21. 'moduleValues' => [
  22. // finder
  23. QRMatrix::M_FINDER | QRMatrix::IS_DARK => 0xA71111, // dark (true)
  24. QRMatrix::M_FINDER => 0xFFBFBF, // light (false)
  25. QRMatrix::M_FINDER_DOT | QRMatrix::IS_DARK => 0xA71111, // finder dot, dark (true)
  26. // alignment
  27. QRMatrix::M_ALIGNMENT | QRMatrix::IS_DARK => 0xA70364,
  28. QRMatrix::M_ALIGNMENT => 0xFFC9C9,
  29. // timing
  30. QRMatrix::M_TIMING | QRMatrix::IS_DARK => 0x98005D,
  31. QRMatrix::M_TIMING => 0xFFB8E9,
  32. // format
  33. QRMatrix::M_FORMAT | QRMatrix::IS_DARK => 0x003804,
  34. QRMatrix::M_FORMAT => 0x00FB12,
  35. // version
  36. QRMatrix::M_VERSION | QRMatrix::IS_DARK => 0x650098,
  37. QRMatrix::M_VERSION => 0xE0B8FF,
  38. // data
  39. QRMatrix::M_DATA | QRMatrix::IS_DARK => 0x4A6000,
  40. QRMatrix::M_DATA => 0xECF9BE,
  41. // darkmodule
  42. QRMatrix::M_DARKMODULE | QRMatrix::IS_DARK => 0x080063,
  43. // separator
  44. QRMatrix::M_SEPARATOR => 0xAFBFBF,
  45. // quietzone
  46. QRMatrix::M_QUIETZONE => 0xDDDDDD,
  47. ],
  48. ]);
  49. // if viewed in the browser, we should push it as file download as EPS isn't usually supported
  50. header('Content-type: application/postscript');
  51. header('Content-Disposition: filename="qrcode.eps"');
  52. echo (new QRCode($options))->render($data);