chroma-x / qr-code-suite
A collection of classes to QR enccode strings and render them as PNG, TIFF and vectorized EPS.
4.0.2
2021-01-18 16:34 UTC
Requires
- php: >=5.3
- ext-gd: *
- ext-imagick: *
- ext-mbstring: *
README
A collection of classes to QR enccode strings and render them as PNG, TIFF and vectorized EPS.
Requirements
To use the QR Code Suite qrencode
and imagick
have to be available.
Installation
{
"require": {
"chroma-x/qr-code-suite": "~2.0"
}
}
Usage
Autoloading and namesapce
require_once('path/to/vendor/autoload.php');
Encoding data as QR code block data
use QrCodeSuite\QrEncode\QrEncoder;
// Encode the data as QR code block data
$encoder = new QrEncoder();
$qrCodeData = $encoder
->setLevel(QrEncoder::QR_CODE_LEVEL_LOW)
->setTempDir('path/to/writable/directory')
->encodeQrCode('https://github.com/chroma-x/php-qr-code-suite');
Render encoded QR code block data as image
use QrCodeSuite\QrRender;
// Render the encoded QR code block data as RGB PNG
$renderer = new QrRender\QrCodeRendererPng();
$renderer->render($qrCodeData, 'path/to/qr-code.png');
// Render the encoded QR code block data as CMYK TIFF
$renderer = new QrRender\QrCodeRendererTiff();
$renderer->render($qrCodeData, 'path/to/qr-code.tif');
// Render the encoded QR code block data as CMYK vectorized EPS
$renderer = new QrRender\QrCodeRendererEps();
$renderer->render($qrCodeData, 'path/to/qr-code.eps');
License
QR Code Suite is under the MIT license.