DEV Community

David | Kordhub
David | Kordhub

Posted on

Generating branded QR codes with logo overlay in Python (PNG + SVG)

The Problem

Most QR code libraries give you a black-and-white square.
That's fine for internal tools, but if you need branded QR codes
for marketing, packaging, or invoices, you need custom colors,
your logo in the center, SVG output for print quality, and high
enough error correction that the QR still scans with a logo on top.

Why error correction matters for logo overlay

When you put a logo in the center of a QR code, you're covering
part of the data. QR codes have built-in error correction —
level H (30%) means the code can still be read even if 30% of it
is obscured. Always use H when adding a logo.

Generating a branded QR code

POST /v1/generate
{
  "data": "https://yoursite.com",
  "format": "png",
  "size": 500,
  "foreground_color": "#2563EB",
  "background_color": "#FFFFFF",
  "error_correction": "H",
  "logo_url": "https://yoursite.com/logo.png"
}
Enter fullscreen mode Exit fullscreen mode

Response — the data field is base64-encoded PNG:

<img src="data:image/png;base64,iVBORw0KGgo..." />
Enter fullscreen mode Exit fullscreen mode

PNG vs SVG

PNG — best for web, apps, and mobile. Supports logo overlay.

SVG — best for print and packaging. Scales infinitely without pixelation. No logo overlay support.

Validate before generating

POST /v1/validate
{
  "data": "your string here",
  "error_correction": "H"
}
Enter fullscreen mode Exit fullscreen mode

Response:

{
  "valid": true,
  "estimated_version": 4,
  "message": "QR version 4 will be used"
}
Enter fullscreen mode Exit fullscreen mode

Higher version = denser QR. Version 40 is the maximum.

Try it free

500 requests/month, no card required:

https://rapidapi.com/kordhubdev/api/kordhub-qr-code-generator

Feedback welcome — especially if you've found edge cases with logo overlay or very long URLs.

Top comments (0)