eps.php 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <?php
  2. /**
  3. * EPS output example
  4. *
  5. * @created 10.05.2022
  6. * @author Smiley <smiley@chillerlan.net>
  7. * @copyright 2022 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\QREps;
  14. require_once __DIR__.'/../vendor/autoload.php';
  15. $options = new QROptions;
  16. $options->version = 7;
  17. $options->outputInterface = QREps::class;
  18. $options->scale = 5;
  19. $options->drawLightModules = false;
  20. // colors can be specified either as [R, G, B] or [C, M, Y, K] (0-255)
  21. $options->bgColor = [222, 222, 222];
  22. $options->moduleValues = [
  23. // finder
  24. QRMatrix::M_FINDER_DARK => [0, 63, 255], // dark (true)
  25. QRMatrix::M_FINDER_DOT => [0, 63, 255], // finder dot, dark (true)
  26. QRMatrix::M_FINDER => [233, 233, 233], // light (false)
  27. // alignment
  28. QRMatrix::M_ALIGNMENT_DARK => [255, 0, 255],
  29. QRMatrix::M_ALIGNMENT => [233, 233, 233],
  30. // timing
  31. QRMatrix::M_TIMING_DARK => [255, 0, 0],
  32. QRMatrix::M_TIMING => [233, 233, 233],
  33. // format
  34. QRMatrix::M_FORMAT_DARK => [67, 159, 84],
  35. QRMatrix::M_FORMAT => [233, 233, 233],
  36. // version
  37. QRMatrix::M_VERSION_DARK => [62, 174, 190],
  38. QRMatrix::M_VERSION => [233, 233, 233],
  39. // data
  40. QRMatrix::M_DATA_DARK => [0, 0, 0],
  41. QRMatrix::M_DATA => [233, 233, 233],
  42. // darkmodule
  43. QRMatrix::M_DARKMODULE => [0, 0, 0],
  44. // separator
  45. QRMatrix::M_SEPARATOR => [233, 233, 233],
  46. // quietzone
  47. QRMatrix::M_QUIETZONE => [233, 233, 233],
  48. // logo space (requires a call to QRMatrix::setLogoSpace()), see imageWithLogo example
  49. QRMatrix::M_LOGO => [233, 233, 233],
  50. ];
  51. $out = (new QRCode($options))->render('https://www.youtube.com/watch?v=dQw4w9WgXcQ', __DIR__.'/qrcode.eps');
  52. if(PHP_SAPI !== 'cli'){
  53. // if viewed in the browser, we should push it as file download as EPS isn't usually supported
  54. header('Content-type: application/postscript');
  55. header('Content-Disposition: filename="qrcode.eps"');
  56. }
  57. echo $out;
  58. exit;