| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- <?php
- /**
- * @created 21.12.2017
- * @author Smiley <smiley@chillerlan.net>
- * @copyright 2017 Smiley
- * @license MIT
- *
- * @noinspection PhpComposerExtensionStubsInspection
- */
- use chillerlan\QRCode\{QRCode, QROptions};
- use chillerlan\QRCode\Data\QRMatrix;
- require_once __DIR__.'/../vendor/autoload.php';
- $gzip = true;
- $options = new QROptions([
- 'version' => 7,
- 'outputType' => QRCode::OUTPUT_MARKUP_SVG,
- 'imageBase64' => false,
- 'eccLevel' => QRCode::ECC_L,
- 'svgViewBoxSize' => 530,
- 'addQuietzone' => true,
- 'svgOpacity' => 1.0,
- 'svgDefs' => '
- <linearGradient id="g2">
- <stop offset="0%" stop-color="#39F" />
- <stop offset="100%" stop-color="#F3F" />
- </linearGradient>
- <linearGradient id="g1">
- <stop offset="0%" stop-color="#F3F" />
- <stop offset="100%" stop-color="#39F" />
- </linearGradient>
- <style>rect{shape-rendering:crispEdges}</style>',
- 'moduleValues' => [
- // finder
- (QRMatrix::M_FINDER << 8) => 'url(#g1)', // dark (true)
- (QRMatrix::M_FINDER_DOT << 8) => 'url(#g1)',
- QRMatrix::M_FINDER => '#fff', // light (false)
- // alignment
- (QRMatrix::M_ALIGNMENT << 8) => 'url(#g1)',
- QRMatrix::M_ALIGNMENT => '#fff',
- // timing
- (QRMatrix::M_TIMING << 8) => 'url(#g1)',
- QRMatrix::M_TIMING => '#fff',
- // format
- (QRMatrix::M_FORMAT << 8) => 'url(#g1)',
- QRMatrix::M_FORMAT => '#fff',
- // version
- (QRMatrix::M_VERSION << 8) => 'url(#g1)',
- QRMatrix::M_VERSION => '#fff',
- // data
- (QRMatrix::M_DATA << 8) => 'url(#g2)',
- QRMatrix::M_DATA => '#fff',
- // darkmodule
- (QRMatrix::M_DARKMODULE << 8) => 'url(#g1)',
- // separator
- QRMatrix::M_SEPARATOR => '#fff',
- // quietzone
- QRMatrix::M_QUIETZONE => '#fff',
- ],
- ]);
- $qrcode = (new QRCode($options))->render('https://www.youtube.com/watch?v=dQw4w9WgXcQ');
- header('Content-type: image/svg+xml');
- if($gzip === true){
- header('Vary: Accept-Encoding');
- header('Content-Encoding: gzip');
- $qrcode = gzencode($qrcode , 9);
- }
- echo $qrcode;
|