eps.php 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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. require_once __DIR__.'/../vendor/autoload.php';
  12. $options = new QROptions([
  13. 'version' => 7,
  14. 'outputType' => QRCode::OUTPUT_EPS,
  15. 'eccLevel' => EccLevel::L,
  16. 'scale' => 5,
  17. 'addQuietzone' => true,
  18. # 'cachefile' => __DIR__.'/test.eps', // save to file
  19. 'moduleValues' => [
  20. // finder
  21. QRMatrix::M_FINDER | QRMatrix::IS_DARK => 0xA71111, // dark (true)
  22. QRMatrix::M_FINDER => 0xFFBFBF, // light (false)
  23. QRMatrix::M_FINDER_DOT | QRMatrix::IS_DARK => 0xA71111, // finder dot, dark (true)
  24. // alignment
  25. QRMatrix::M_ALIGNMENT | QRMatrix::IS_DARK => 0xA70364,
  26. QRMatrix::M_ALIGNMENT => 0xFFC9C9,
  27. // timing
  28. QRMatrix::M_TIMING | QRMatrix::IS_DARK => 0x98005D,
  29. QRMatrix::M_TIMING => 0xFFB8E9,
  30. // format
  31. QRMatrix::M_FORMAT | QRMatrix::IS_DARK => 0x003804,
  32. QRMatrix::M_FORMAT => 0x00FB12,
  33. // version
  34. QRMatrix::M_VERSION | QRMatrix::IS_DARK => 0x650098,
  35. QRMatrix::M_VERSION => 0xE0B8FF,
  36. // data
  37. QRMatrix::M_DATA | QRMatrix::IS_DARK => 0x4A6000,
  38. QRMatrix::M_DATA => 0xECF9BE,
  39. // darkmodule
  40. QRMatrix::M_DARKMODULE | QRMatrix::IS_DARK => 0x080063,
  41. // separator
  42. QRMatrix::M_SEPARATOR => 0xAFBFBF,
  43. // quietzone
  44. QRMatrix::M_QUIETZONE => 0xDDDDDD,
  45. ],
  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');
  53. exit;