Adding a Logo
A logo in the centre makes a code recognisably yours, and reassures a payer that they're scanning the right thing.
RaastQr::make()
->amount('2500')
->logo(public_path('logo.png'))
->toPng();Sizing It
RaastQr::make()->logo(public_path('logo.png'), size: 120)->toPng();The size argument is the logo's width in pixels. Leave it out and the image is used at its natural size.
Keep it under a fifth
A QR code recovers from damage, but only so much. As a rule of thumb, keep the logo under about 20% of the code's width, and always pair it with errorCorrection('H').
A 900px code can carry a 140–180px logo comfortably. Push past that and you'll start getting codes that scan on your phone and fail on your customer's.
Punchout
RaastQr::make()->logo(public_path('logo.png'), size: 120, punchout: false)->toPng();By default the logo punches a clean hole in the code behind it, so a transparent PNG sits on the background colour rather than on top of black modules. Set punchout: false to draw the logo directly over the code.
Punchout on is almost always what you want.
Setting a Default Logo
If every code should carry the same mark, configure it once:
// config/raast-qr.php
'logo' => [
'path' => storage_path('app/brand/mark.png'),
'size' => 140,
'punchout' => true,
],Then no builder call is needed:
RaastQr::make()->amount('2500')->toPng(); // logo includedPer-Tenant Logos
RaastQr::make()
->iban($tenant->iban)
->amount($order->total)
->when($tenant->logo_path, fn ($qr) => $qr->logo(
Storage::disk('public')->path($tenant->logo_path), 140
))
->toPng();Errors
A missing file fails fast rather than silently rendering a plain code:
try {
RaastQr::make()->logo('/nope/logo.png')->toPng();
} catch (RaastQrException $e) {
$e->reason(); // 'INVALID_QR_OPTIONS'
}Always Test the Result
Whenever you change a logo, its size, or the error correction level, scan the output before you ship it. A logo is the one customisation that can silently break a code while still looking perfectly fine.
Made with ❤️ from Pakistan