eps.php 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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\Common\EccLevel;
  10. use chillerlan\QRCode\Data\QRMatrix;
  11. use chillerlan\QRCode\Output\QROutputInterface;
  12. require_once __DIR__.'/../vendor/autoload.php';
  13. $options = new QROptions([
  14. 'version' => 7,
  15. 'outputType' => QROutputInterface::EPS,
  16. 'eccLevel' => EccLevel::L,
  17. 'scale' => 5,
  18. 'addQuietzone' => true,
  19. # 'cachefile' => __DIR__.'/test.eps', // save to file
  20. 'moduleValues' => [
  21. // finder
  22. QRMatrix::M_FINDER | QRMatrix::IS_DARK => 0xA71111, // dark (true)
  23. QRMatrix::M_FINDER => 0xFFBFBF, // light (false)
  24. QRMatrix::M_FINDER_DOT | QRMatrix::IS_DARK => 0xA71111, // finder dot, dark (true)
  25. // alignment
  26. QRMatrix::M_ALIGNMENT | QRMatrix::IS_DARK => 0xA70364,
  27. QRMatrix::M_ALIGNMENT => 0xFFC9C9,
  28. // timing
  29. QRMatrix::M_TIMING | QRMatrix::IS_DARK => 0x98005D,
  30. QRMatrix::M_TIMING => 0xFFB8E9,
  31. // format
  32. QRMatrix::M_FORMAT | QRMatrix::IS_DARK => 0x003804,
  33. QRMatrix::M_FORMAT => 0x00FB12,
  34. // version
  35. QRMatrix::M_VERSION | QRMatrix::IS_DARK => 0x650098,
  36. QRMatrix::M_VERSION => 0xE0B8FF,
  37. // data
  38. QRMatrix::M_DATA | QRMatrix::IS_DARK => 0x4A6000,
  39. QRMatrix::M_DATA => 0xECF9BE,
  40. // darkmodule
  41. QRMatrix::M_DARKMODULE | QRMatrix::IS_DARK => 0x080063,
  42. // separator
  43. QRMatrix::M_SEPARATOR => 0xAFBFBF,
  44. // quietzone
  45. QRMatrix::M_QUIETZONE => 0xDDDDDD,
  46. ],
  47. ]);
  48. if(php_sapi_name() !== 'cli'){
  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. }
  53. echo (new QRCode($options))->render('https://www.youtube.com/watch?v=dQw4w9WgXcQ');
  54. exit;