1. Go to this page and download the library: Download sqrart/qart library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
use SqrArt\QArt\Cache\FileMatrixCache;
use SqrArt\QArt\QArtGenerator;
use SqrArt\QArt\RenderProfile;
$generator = new QArtGenerator(
prefix: 'https://sqr.art/',
errorBudgetPerBlock: 1, // RS codewords sacrificed per block (capped by version/ECC)
matrixCache: new FileMatrixCache('/tmp/qart-cache'), // ~4 s saved per generation
maxAttempts: 3, // retry with a new serial if the decode fails
);
$result = $generator->generate('photo.jpg', 'qr.png', RenderProfile::screen());
$result->url; // full encoded URL (271 characters)
$result->suffix; // store this for the lookup GET /{suffix}
$result->serial; // first 8 characters of the suffix (40 bits of entropy)
$result->mask; // chosen QR mask (best fidelity score)
$result->attempts; // 1 unless a regeneration was needed
$result->warnings; // upscaled image, low contrast…
use SqrArt\QArt\UrlMode;
$gen = new QArtGenerator(prefix: 'https://sqr.art/', urlMode: UrlMode::Short);
$res = $gen->generate('photo.jpg', 'qr.png');
$res->url; // https://sqr.art/UKmohnVJ — 24 characters, clean at scan time
$res->suffix; // the serial alone (8 characters) for the lookup
use SqrArt\QArt\ImportanceMap;
$importance = (new ImportanceMap)->protect(x: 0.38, y: 0.18, w: 0.34, h: 0.45);
$res = $gen->generate('photo.jpg', 'qr.png', importance: $importance);
$res->protectedMismatches; // 0 = zone guaranteed; otherwise a warning
use SqrArt\QArt\Fit;
$gen->generate('logo-large.png', 'qr.png', fit: Fit::Contain);
$importance = (new ImportanceMap)->paint(file_get_contents('mask.png'));
// free crop: source square as fractions (x, y of the origin,
// size as a fraction of the short side) — default: centred square
$res = $gen->generate('photo.jpg', 'qr.png',
importance: $importance,
crop: ['x' => 0.15, 'y' => 0.0, 'size' => 0.8],
);