Home

Awesome

ComfyQR

A set of ComfyUI nodes to dynamically create QR image layers for generative QR art without the hassle of leaving the webui.

Everything in this pack is primarily focused on the creation of patterns. While the Mask QR Errors does some basic statistics on the differences between pixels, a more definative node on determining scannability can be found in the companion project ComfyQR-scanning-nodes which uses additional dependencies for the reading of QRs.

This repository is managed publicly on Gitlab, but also mirrored on Github. Please submit any issues or pull requests to the gitlab repo.

QR code with repo link

Getting started

This project currently contains two nodes for generating QR codes.

QR Code and QR Code (Split)

A dynamically sized QR code without any resampling scaled by the text length, the module size, and the error correction level. Use the QR Code for simple workflows and the QR Code (Split) if you want to build more advanced pipelines with additional outputs for the MODULE_LAYER, FINDER_LAYER, or FINDER_MASK.

Split QR Code Node Example

Inputs

Outputs

QR Code (Conformed to Image Size)

Conformed QR Code Node Example

A QR code fixed to specific output dimensions through image resampling.

Inputs

Outputs

Mask QR Errors

A node that that will analyze the differences between a modified QR and create a mask of the estimated errors.

Mask QR Errors Node Example

Note: This is an extremly powerful node but relies on several assumptions in order to be used.

  1. A QR with a fixed module size that has not been resampled irregularly or distorted.
  2. Shared allignment between the source_qr and modified_qr.
  3. Fill and back colors must be perfectly white and black (#FFFFFF, #000000) for the source_qr.
  4. The canvas can be bigger than the QR code, but on the source_qr, there should be no pixels the same color as the module color outside of the QR exterior.

Inputs

Outputs

Examples

There is an assortment of workflow examples that can be found in the examples directory or in the metadata of the images in the example_generations folder. For example taking this image.

Bad Scan Example

And then aggressively increasing the strength of the ControlNet on only the error pixels to make something previously completely unscannable more reliably across different monitors and QR readers.

Fixed Scan Example

Any workflow in the example that ends with "validated" (and a few image examples) assume the installation of the scanning pack as well.

Alternate Module Drawers

The QR generation nodes now support alternate module styles. Experiment using different ones for greater flexibility during generation.

SquareGapped SquareCircleRoundedVertical barsHorizontal bars
Example QRExample QRExample QRExample QRExample QRExample QR

Note Even unaltered non square styles will inherently register small deviations from RMSE values and possible minute deviations for correlations when using the Mask QR Errors node. When information is extracted, the source_qr values are rounded so that they can only be 0 or 1 (to allow alternate drawers to be used as inputs) and matched against the unrounded aggregation of the modified_qr values.

Future updates

If the solution is clean enough and if it can definitively improve scannability, there may be additional plans for the seperation of alignment patterns (based on module_size, border, and QR_VERSION) for more advanced workflows.