#40 - QR Code with custom logo in the center in PHP

Data: 2018-12-22 12:00 - PHP

Simple PHP script to output a QR code with a logo in the center.

// using the QRCode library by https://github.com/kazuhikoarase/qrcode-generator
$qr = QRCode::getMinimumQRCode('https://icy.pt/', QR_ERROR_CORRECT_LEVEL_L);
$img = $qr->createImage(6, 2);
header('Content-type: image/png');

$w = imagesx($img);
$h = imagesy($img);

$logo = imagecreatefrompng(__DIR__ . '/logo-32px.png');
imagecopy($img, $logo, $w/2 - 16, $h/2 - 16, 0, 0, 32, 32);

imagepng($img);
imagedestroy($img);

Previous snippet | Next snippet