3 minute read

IBM branded QR code QR codes are widely used in our products for everything from onboarding, sharing links to enabling easy access to services. While they’re a quick and reliable solution, they tend to look generic, which can reduce their impact, especially in marketing or branding contexts.

In this post, I’ll walk through how to generate branded QR codes in Java using the ZXing library, and how to seamlessly embed a logo into the code without compromising scannability.

Tools and Libraries

  1. Java 17 (or any recent version), compatible with modern libraries.
  2. ZXing as the go-to solution for generating QR codes, providing an easy way to create and manipulate QR codes. You’ll need the core ZXing library (zxing-core) and the Java SE version (zxing-javase)
  3. GIMP (optional) to prepare and size your logo to fit within the QR code. I followed this tutorial to create the logos used in the demo app.

How it works

To embed a logo in a QR code, the ZXing library is used to generate the code with a high error correction level (EncodeHintType.ERROR_CORRECTION = ErrorCorrectionLevel.H). This setting allows a portion of the QR code to be obscured without making it unreadable.

The logo is overlaid at the center of the QR code and typically sized to not exceed 20–30% of the QR area. In the demo app, I generate the QR code dynamically from input data, but you could also apply a logo to a static QR code image.

The key is to avoid blocking the QR code’s essential data regions. Once the QR code and logo are combined, the resulting image remains scannable.

Code Walkthrough

This example keeps things simple — just enough to generate a QR code, apply a logo in the center, and export the final image as a PNG. Here’s a breakdown of the core implementation steps:

  1. Set High error correction.

  2. Generate QR code from input data.

  3. Load an image file (the logo) from the application’s resource folder.

  4. Calculate 20% of the size if the QR code and center the logo.

  5. Resize the logo and create new blank image with alpha channel.

  6. Combines the QR code and the centered logo into a single image, with smooth rendering.

  7. Writes the combined image to the file system.

Demo app

I posted a demo application showcasing the generation of branded QR codes here: https://github.com/chagemann/Branded-QR-Codes

The logo image should be placed in the ./app/src/main/resources/ directory, and the output image will be saved in the ./app folder. Then execute it with ./gradlew build run.

Here are two more examples of how that could look like:

IBM branded QR code IBM branded QR code

Summary

Branded QR codes are a simple yet powerful enhancement to add a layer of visual identity to an otherwise plain tool. With the help of Java and the ZXing library, it’s easy to automate their generation and integrate them into your application or service pipeline.

Whether you’re improving user trust, strengthening your brand presence, or simply experimenting with custom visuals, this technique is a valuable addition to your development toolkit.


“Nothing lasts as long as a temporary solution.”

– Milton Friedman

Leave a comment