Nodes/ComfyUI-QING/加载图像丨SVG
ComfyUI Node

加载图像丨SVG

Load an SVG in ComfyUI without watching LoadImage choke on it

By sheengoa·Created about a year ago·Updated 20 days ago· 16
加载图像丨SVG
    • image
    • mask
    • svg_content
    • format_info
    image

    Core ComfyUI's LoadImage is happy with PNGs, JPEGs, and WebPs, and that's about it. Hand it an SVG and it dies - but SVGs are genuinely useful in ComfyUI: they're the vector path to sharp, resolution-independent assets, and the QING pack even ships SVGToImage to rasterize them. CustomLoadImageWithFormat is the loader that bridges the gap. Point it at a file in your input/ folder and it reads whatever it is, then routes the result to the right output port based on the format: bitmaps get their image and mask, SVGs get their raw XML content as a string. Same dropdown-picker UX as core LoadImage, just with the format intelligence added.

    It lives in ComfyUI-QING's input/output category (display name 加载图像丨SVG) and is an output node, so you wire its outputs onward or use it as a terminal loader feeding a rasterizer.

    How it works. It lists the files in your input directory (with the upload button enabled, so you can drop a file through the widget). On load it checks the extension and, for extra accuracy on JPEGs, sniffs the file header. The behavior per format:

    • Bitmaps (PNG/JPEG/WebP/etc.) → returns image (IMAGE) and mask (MASK) as normal, with the svg_content port set to a placeholder.
    • SVG → reads the file, validates it's actually SVG, and returns the raw XML in svg_content, with image/mask set to placeholders.
    • Either way, format_info tells you what it detected.

    That "one port is a placeholder for the other format" split is the thing to understand: the node is a fork, not a converter. You pick the output based on what you loaded.

    The inputs and outputs that matter.

    • image - the file picker (enum over your input dir, upload-enabled). That's the only input.
    • Outputs: image, mask, svg_content, and format_info.

    If you loaded an SVG, wire svg_content into SVGToImage (or your own cairosvg path) to get pixels. If you loaded a bitmap, ignore svg_content entirely. format_info is a nice debugging output - feed it to a text preview to confirm what the loader actually saw.

    How to install. ComfyUI-QING is one pack - search "ComfyUI-QING" in ComfyUI Manager, or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/GAO-SHIQING/ComfyUI-QING
    cd ComfyUI-QING
    python install_dependencies.py
    

    The pack's own requirements include cairosvg (recommended for rasterizing SVG), so the SVG path is covered out of the box. Restart after installing. The README's clone URL is typo'd (GAOSHI-QING, missing the H) - use the URL above or Manager.

    Troubleshooting. The main surprise is that an SVG loads as text, not pixels - if you wire svg_content somewhere expecting an image, nothing renders. Route it through a rasterizer. Second: for SVGs the image/mask outputs are placeholders, and the reverse is true for bitmaps - grabbing the wrong port gives you garbage or nothing, and format_info is how you tell which branch you're on. And if a file genuinely isn't an SVG but has a .svg extension, the validator rejects it with an "Invalid SVG content" error rather than guessing - the error goes to the node's UI text. Drop your files into ComfyUI/input/ and the picker will show them after a refresh.

    CategoryQING/输入输出

    Inputs (1)

    NameTypeDefaultDescription
    imageCOMBO1 options: example.png

    Outputs (4)

    NameTypeDescription
    imageIMAGE
    maskMASK
    svg_contentSTRING
    format_infoSTRING