Notes · Guide

Add a logo to a QR code without breaking it

Install QR Studio for PHP, generate a styled QR code, and avoid the two scan failures: low contrast and a logo with no error-correction headroom.

3 min read Updated Sep 21, 2026 PHP

Add a logo to a QR code without breaking it

This guide installs the free QR Studio library for PHP and generates a styled QR code: a shaped module, a coloured frame, a centre logo. It also covers the two specific, avoidable reasons a “designed” QR code fails to scan more often than a plain black-and-white one, because installing the library is the easy five minutes and getting a logo’d code to actually scan is the part people trip on. Budget ten minutes.

Requirements

PHP 8.4 or newer, inherited from the underlying endroid/qr-code 6.x engine rather than a preference of mine. The GD extension is needed for PNG output; SVG output needs nothing extra.

1. Install

composer require remymazmanian/qr-studio

That’s the whole install. There’s nothing to configure and no API key, since everything renders locally.

2. Generate a plain code

use QrStudio\QrRenderer;

$renderer = new QrRenderer();

file_put_contents('qr.svg', $renderer->result('https://example.com', 'svg')->getString());

That covers a URL. For a phone number, email, Wi-Fi network, or contact card, build the payload with PayloadFactory instead of hand-writing the string, since Wi-Fi and vCard payloads are delimiter-separated and an unescaped ; or : in a network name will otherwise produce a QR code that scans to the wrong thing:

use QrStudio\PayloadFactory;

$payload = (new PayloadFactory())->make([
    'type'            => 'wifi',
    'wifi_ssid'       => 'Guest',
    'wifi_password'   => 'pw',
    'wifi_encryption' => 'WPA',
]);

3. Add style

DesignOptions controls module shape, eye shape, frame, colour, a centre logo, and a caption:

use QrStudio\DesignOptions;

$options = DesignOptions::fromArray([
    'module_style'     => DesignOptions::MODULE_DOTS,
    'eye_style'        => DesignOptions::EYE_CIRCLE,
    'frame_style'      => DesignOptions::FRAME_ROUNDED_CARD,
    'foreground_color' => '#1f3d7a',
    'label_text'       => 'Scan me',
]);

file_put_contents('styled.png', $renderer->result('https://example.com', 'png', $options)->getString());

Styling is also where codes start failing to scan. It happens in two ways.

Reason one: not enough contrast

A phone’s camera locks onto a QR code by finding sharp light-to-dark transitions. A light grey code on a white background, or a brand colour that is close in luminance to its background, removes exactly the signal the scanner is looking for. It often still looks fine to a human eye and still fails in the parking lot with real light on it.

The fix is to check the ratio before the code ships. ColorContrast implements the same WCAG relative-luminance formula browsers use for text contrast:

use QrStudio\ColorContrast;

if (ColorContrast::contrastRatio('#1f3d7a', '#ffffff') < 3.0) {
    // reject this pairing before it ever renders
}

Treat 3.0 as a practical floor. Below it, expect scan failures on lower-end cameras and in bad lighting.

Reason two: a logo with no headroom

QR codes carry redundant data on purpose, controlled by an error correction level, so the code still reads even if part of it is dirty, torn, or covered by a logo. The redundancy has a ceiling. A logo dropped onto a code built at the default error correction level eats past that ceiling, and the result reads fine in a browser preview and fails on an actual phone, because the preview doesn't check redundancy, it just renders pixels.

Two rules fix this. Push error correction to high whenever a logo is present, and keep the logo at or below roughly 25% of the code's area. QR Studio enforces the second one as a hard cap on logo_size_percentage rather than a suggestion in the README you can miss:

$options = DesignOptions::fromArray([
    'error_correction_level' => 'high',
    'logo_path'               => '/path/to/logo.png',
    'logo_size_percentage'    => 20,
]);

file_put_contents('branded.png', $renderer->result('https://example.com', 'png', $options)->getString());

logo_path is an absolute filesystem path. The library deliberately knows nothing about upload directories or URL schemes; resolving a user upload to a real path is the calling application's job.

Test it the way a customer will

Neither check replaces actually scanning the output. Print it at the real size it will ship at, not a laptop screen at full brightness, and scan it with an ordinary phone from a normal distance. A code that only scans when it fills your monitor will fail on a business card.

Try every option without writing code

The repo includes a single-file demo with live preview, all six payload types, and every style control, including a logo file upload:

git clone https://github.com/remymazmanian/qr-studio.git
cd qr-studio
composer install
composer demo

Then open localhost:8080. It accepts a logo upload, so treat it as a local playground rather than something to expose on a public host as-is.

Full option reference, all six payload types, and the source: github.com/remymazmanian/qr-studio, MIT licensed.