merge() method lets you embed a logo or image directly into the center of a QR code. This is a common branding technique — the QR code remains fully scannable as long as the logo does not cover too much of the data area.
How It Works
Callmerge() before generate(), passing the image path and the proportion of the QR it should occupy.
| Parameter | Type | Description |
|---|---|---|
$filepath | string | Path to the image file to embed. Relative paths are resolved from your project root; absolute paths are used as-is. |
$percentage | float | Fraction of the QR width the image should occupy (e.g. 0.3 = 30 %). Default: 0.2 |
Supported Formats
Image merge works with all output formats: PNG, WebP, SVG, and EPS.EPS merging requires the
GD PHP extension. PNG and WebP merging requires
either Imagick or GD. SVG merging has no additional PHP extension
requirements.Basic Examples
- PNG with logo
- SVG with logo
- WebP with logo
Use High Error Correction
When you embed a logo you are physically covering part of the QR code’s data modules. QR codes compensate for this through built-in error correction. Set the level to H (30 % recovery) whenever you merge an image.Save to a File
Pass a second argument togenerate() to write the result directly to disk.
Merging an In-Memory Image String
If you already have the image content as a string (e.g. fetched from remote storage), usemergeString() instead of merge().
Best Practices
Keep the logo under 30 % of the QR area
A
$percentage value above 0.3 risks making the code unreadable on lower-quality scanners. Stay at 0.3 or below for maximum compatibility.Always use error correction level H
Call
->errorCorrection('H') every time you use merge(). This maximises the redundancy available to compensate for the obscured modules.Use a simple, high-contrast logo
Complex logos with thin lines or subtle colour gradients are harder to distinguish at small sizes. A simple monochrome or flat-colour logo works best.
Complete Branded Example
Styling
Control module shape, eye style, size, margin, and format.
Colors
Apply RGB, CMYK, grayscale, gradients, and per-eye color overrides.