Nodes/ComfyUI-ZML-Image/ZML_合并图像
ComfyUI Node

ZML_合并图像

Composite up to four images with a built-in editor, no Photoshop required

By zml-w·Created about a year ago·Updated 2 months ago· 218
ZML_合并图像
  • 底图
  • 前景图_1
  • 前景图_2
  • 前景图_3
  • 图像
transform_data{}

Every serious workflow eventually needs to stack images on top of each other - paste a watermark, composite a character onto a background, build a comparison grid - and the stock answer in ComfyUI is either a compositing node that expects you to calculate every x/y coordinate yourself, or an external editor. ZML_MergeImages is the author's answer: a merge node with a built-in visual editor where you drag layers around on a canvas and the node remembers what you did.

The README is explicit about the design goal: other merge nodes existed, but the author found them "not too easy to operate," so he made his own. You don't run the workflow to see the result - you click a button, edit visually, and the layout is saved into the node, so it replays on every future run.

How it works

The inputs are a base layer plus up to three foregrounds:

  • 底图 - the background.
  • 前景图_1 (required) - the first layer on top.
  • 前景图_2, 前景图_3 (optional) - two more layers.
  • transform_data - a hidden STRING field (default {}) that holds the saved layout as JSON. You normally never touch this; the editor writes it. But it's the reason the node "remembers" your positions, and it's stored in the workflow, so the layout travels with the file.

Click the node's edit button and a canvas opens where each foreground layer can be moved, scaled, rotated, and faded via an opacity slider. On execution, the node reads that stored JSON and replays it: each layer is resized (scaleX/scaleY), rotated (angle), alpha-adjusted (opacity), and pasted at its saved left/top position using PIL with LANCZOS resampling. It handles batches too - a batch of base images gets the same layer stack applied to every frame.

Output is a single 图像 (IMAGE), composited in RGB.

The details that make it nice

  • Opacity per layer. That's the README's "合并图像节点加了个调节前景图不透明度的功能" - genuinely useful for watermarks, since a subtle mark beats a shouty one.
  • RGBA-aware. Foregrounds with transparency paste correctly, using the alpha channel as the mask.
  • Safe failure. If transform_data is unparseable (say, a workflow edit mangled it), it just returns the base image and logs a message instead of crashing the whole graph.

When you'd reach for it

Watermarking is the canonical use - the README explicitly says it's good for 打码 (blurring/censoring) and compositing. Comparison grids (same image, different seeds or CFGs side by side) are another. And for the pack's own ecosystem, it pairs naturally with the ZML save nodes that keep the workflow embedded in the PNG (see the KB's image-io-metadata doc for why that matters).

Install

This is one node in ComfyUI-ZML-Image:

cd ComfyUI/custom_nodes
git clone https://github.com/zml-w/ComfyUI-ZML-Image
# restart ComfyUI

or ComfyUI Manager → search "ComfyUI-ZML-Image". Needs Pillow (pack baseline) plus the frontend's fabric.js bundle which ships with the pack - nothing extra to download. Chinese-first UI; translation patch at https://github.com/zml-w/ZZZ_ZML_English_Patch.

The editor is one of the pack's heavier UI pieces, and a fair chunk of the README's update notes over the months is bug fixes to the pack's visual editors ("修复了可视化调色节点的版本错误问题,并修复了其全部功能"). So if the editor misbehaves on an odd ComfyUI version, don't be shocked - it's the kind of node where the author would actually want a bug report. The core compositing math, though, is solid.

Categoryimage/ZML_图像/高级图像工具

Inputs (5)

NameTypeDefaultDescription
底图IMAGE
前景图_1IMAGE
transform_dataSTRING{}
前景图_2optIMAGE
前景图_3optIMAGE

Outputs (1)

NameTypeDescription
图像IMAGE