Dev split function patterns See merge request sofuego-comfy-nodes/comfy-qr!1
comfy-qr
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 for the purpose of creating patterns. If you would like to evaluate rendered patterns for scannability, check out the companion project Comfy QR Validation Nodes. Any workflow in the example that ends with "validated" assume the installation of the validation pack as well.
This repository is managed publicly on Gitlab, but also mirrored on Github. Please submit any issues or pull requests to the gitlab repo.
Getting started
This project currently contains two nodes for generating QR codes.
QR Code
A dynamically sized QR code without any resampling scaled by the text length, the module size, and the error correction level.
Inputs
protocol- If enabled this will prefix the textbox input with a preset to represent the internet protocol. This is included both for convenience and as a workaround for the textbox clipping strings with this character combination.Http- Adds "http://" before the text.Https- Adds "https://" before the text.None- Uses only the contents of thetextbox.
text- What text to build your QR code with. Ifprotocolis specified, this textbox will be combined it with the selected option.module_size- The pixel width of the smallest unit of a QR code.max_image_size- The maximum size of the resulting QR code. If the combination oftext,module_size, anderror_correctioncreate dimensions that exceed this, an error will halt the pipeline.fill_hexcolor- A string of characters representing the hex value of the QR units. Can be 3 or 6 hexadecimal characters with an optional # before.back_hexcolor- A string of characters representing the hex value of the space around the QR units. Can be 3 or 6 hexadecimal characters with an optional # before.error_correction- The level of error correction to apply.Low- 7% error correction.Medium- 15% error correction.Quartile- 25% error correction.High- 30% error correction.
border- The border size (In multiples ofmodulewidths)
Outputs
IMAGE- The QR codeQR_VERSION- An integer of the QR version that was selected based on the text length and error correction level.IMAGE_SIZE- An integer based on the pixel width of the resulting QR code.
QR Code (Conformed to Image Size)
A QR code fixed to specific output dimensions through image resampling.
Inputs
protocol- If enabled this will prefix the textbox input with a preset to represent the internet protocol. This is included both for convenience and as a workaround for the textbox clipping strings with this character combination.Http- Adds "http://" before the text.Https- Adds "https://" before the text.None- Uses only the contents of thetextbox.
text- What text to build your QR code with. Ifprotocolis specified, this textbox will be combined it with the selected option.image_size- The pixel dimensions to conform the QR code to.fill_hexcolor- A string of characters representing the hex value of the QR units. Can be 3 or 6 hexadecimal characters with an optional # before.back_hexcolor- A string of characters representing the hex value of the space around the QR units. Can be 3 or 6 hexadecimal characters with an optional # before.error_correction- The level of error correction to apply.Low- 7% error correction.Medium- 15% error correction.Quartile- 25% error correction.High- 30% error correction.
border- The border size (In multiples ofmodulewidths)resampling- The resampling algorithm to use when rescaling the QR code.Bicubic- Bicubic interpolationBilinear- Bilinear interpolationBox- Box interpolationHamming- Hamming interpolationLanczos- Lanczos interpolationNearest- Nearest Neighbor interpolation
Outputs
IMAGE- The QR codeQR_VERSION- An integer of the QR version that was selected based on the text length and error correction level.
QR Code (Split)
A version of the QR Code node that also outputs split layers for the function patterns and a mask for the function patterns.
Inputs
protocol- If enabled this will prefix the textbox input with a preset to represent the internet protocol. This is included both for convenience and as a workaround for the textbox clipping strings with this character combination.Http- Adds "http://" before the text.Https- Adds "https://" before the text.None- Uses only the contents of thetextbox.
text- What text to build your QR code with. Ifprotocolis specified, this textbox will be combined it with the selected option.module_size- The pixel width of the smallest unit of a QR code.max_image_size- The maximum size of the resulting QR code. If the combination oftext,module_size, anderror_correctioncreate dimensions that exceed this, an error will halt the pipeline.fill_hexcolor- A string of characters representing the hex value of the QR units. Can be 3 or 6 hexadecimal characters with an optional # before.back_hexcolor- A string of characters representing the hex value of the space around the QR units. Can be 3 or 6 hexadecimal characters with an optional # before.error_correction- The level of error correction to apply.Low- 7% error correction.Medium- 15% error correction.Quartile- 25% error correction.High- 30% error correction.
border- The border size (In multiples ofmodulewidths)
Outputs
QR_FLATTENED- The QR codeMODULE_LAYER- The QR code with theback_hexcolorfilling in the function patterns (to remove their influence from the early diffusion steps).FINDER_LAYER- The isolated finder patterns over theback_hexcolor.FINDER_MASK- A mask that isolates the locations of the 3 finder patterns.QR_VERSION- An integer of the QR version that was selected based on the text length and error correction level.IMAGE_SIZE- An integer based on the pixel width of the resulting QR code.
Future updates
If the solution is clean enough and if it can definitively improve scanability, there may be additional plans for the seperation of alignment patterns (based on module_size, border, and QR_VERSION) for more advanced workflows.
