Nodes/ComfyUI_to_webui/hua_Barcode Generator
ComfyUI Node

hua_Barcode Generator

Generate Code128 barcodes as images, right inside your workflow

By kungful·Created 2 years ago·Updated 8 months ago· 25
hua_Barcode Generator
    • 条形码图像
    • 尺寸遮罩
    • 输出数字
    前缀
    输入数字0
    字体大小25
    条码高度缩放0.5
    文本下边距15
    条码与文本间距10
    左右边距2.0
    顶部边距5
    全局缩放比例1.0

    BarcodeGeneratorNode (hua_Barcode Generator) renders a Code128 barcode as an actual ComfyUI image tensor, with the number printed underneath it - for the oddly specific use case of generating product labels or serial-number tags as part of an image pipeline. It's one of the pack's "graph-side" helpers: it does its thing in the workflow and never shows up in the Gradio frontend. Nothing about it is AI, but if you're building a label-generation or serialized-asset workflow, it's exactly the right tool, because it's already a tensor when it comes out.

    The mechanism is python-barcode plus PIL: it takes your number, renders it as Code128 at a configurable DPI, then composes a white canvas with the barcode on top and your prefix+number as centered text below it, using the SimHei font that ships in the pack's fonts/ folder. The output is a clean RGB tensor plus a matching all-ones mask (so the whole thing is compositable as an opaque region) and the number as a string. It's unambiguously a number barcode - letters don't play well with Code128 here.

    Inputs are Chinese-named in the schema; here's the short list of what actually matters:

    • 输入数字 ("Input Number") - the INT to encode. Default 0. This is the one you'll feed from a seed or counter.
    • 前缀 ("Prefix") - optional text drawn next to the number (default empty).
    • 全局缩放比例 ("Global Scale") - scales the whole canvas 0.1–10x; default 1.
    • 字体大小 / 条码高度缩放 / 文本下边距 / 条码与文本间距 / 左右边距 / 顶部边距 - font size, bar-height ratio, and assorted margins. The defaults are reasonable; adjust only if your label is cramped.

    Outputs: 条形码图像 (IMAGE), 尺寸遮罩 (MASK), 输出数字 (STRING). Note the string output is just the input number echoed back - the source has a half-finished idea about auto-incrementing here (comments about "last_number" are still in the code) but it doesn't increment. To get a fresh number per run, feed it from the seed node.

    Install: it ships with ComfyUI_to_webui - ComfyUI Manager → "ComfyUI_to_webui", or

    cd ComfyUI/custom_nodes
    git clone https://github.com/kungful/ComfyUI_to_webui.git
    

    restart. The python-barcode dependency is in the pack's requirements and auto-installs; no models involved.

    Honest assessment: this node is a niche within a niche. If you only generate art, skip it. But if you've ever hand-built a barcode label in a compositing tool, you know the pain this removes - it's on-canvas, re-renders on every run, and the mask output makes stamping it onto product shots trivial. The couple of rough edges (no auto-increment, Chinese-only input names) are worth knowing, but they don't stop it doing the job.

    Category❤️ 靓仔 ✨

    Inputs (9)

    NameTypeDefaultDescription
    前缀STRING
    输入数字INT00–18446744073709550000
    字体大小INT2510–200
    条码高度缩放FLOAT0.50.1–3
    文本下边距INT155–50
    条码与文本间距INT10-80–50
    左右边距FLOAT2.00–20
    顶部边距INT50–100
    全局缩放比例FLOAT1.00.1–10

    Outputs (3)

    NameTypeDescription
    条形码图像IMAGE
    尺寸遮罩MASK
    输出数字STRING