PIL Merge Image (Mexx)
It merges images — but not the way you're picturing
- image
- image2
- image3
- image4
- image5
- image6
- result_img
PIL Merge Image (Mexx) takes up to six images and combines them into one. Before you get excited, read this next sentence twice: it does not put two full images side by side. It slices each image into strips and stitches the strips into a canvas that's the same size as the originals. So "左右" (left-right) with two images gives you the left half of image one fused with the right half of image two - a hybrid, not a panorama. If you expected a tiled side-by-side at double width, this is not that tool; a general image-compositing pack is what you want.
That's a weird design, but once you see what it's for, it clicks. This pack comes from the comic/manga corner of the ecosystem (SoftMeng, the same author as ComfyUI-DeepCache-Fix - this is a side project). When you're assembling a page where every panel must share one canvas at one resolution, a slice-merge that keeps the canvas fixed is actually the useful behavior. It's also a fast way to A/B a generation: keep the best half of each render and weld them into one image.
How it works
All images go through tensor2pil, and then the mode decides:
- 左右 (left-right) - each image is cropped to an equal-width vertical strip (
width // number_of_images) and the strips are pasted left to right. Two images = 50/50 split. - 上下 (up-down) - same idea, horizontal strips stacked.
- 平行四边形 (parallelogram) - a diagonal-wipe composite. Image 2 gets a parallelogram-shaped alpha mask and is blended over image 1, so you get a slanted transition rather than a straight seam. This one only makes sense with two inputs.
It's batch-safe like the rest of the pack, so each frame in a batch gets merged independently.
Inputs
- merge_type - the three modes above, default 左右.
- image, image2 - required. image3 through image6 are optional, so you can merge 2 to 6 inputs.
- Output: a single
result_imgIMAGE.
All images must be exactly the same pixel size. If any differ from the first, the node raises ValueError: All images must be the same size and you get nothing. Resize everything to a common resolution before this node - the pack has no resize helper, so do it in the graph (e.g. with a standard image-size node) or you'll be fighting this error.
Install
cd ComfyUI/custom_nodes
git clone https://github.com/SoftMeng/ComfyUI-PIL
Restart, or search "ComfyUI-PIL" in ComfyUI Manager. No requirements.txt, no models, just Pillow and numpy that ComfyUI already has. Nothing else in the pack is required to use this node, though the ~55 MB of bundled fonts comes with the clone.
Gotchas
The strip math means you can't control where the seams land - with two images it's always a clean 50/50 split, with three a 33/33/33, and so on. There's no gap, no border, no offset option. And again: output dimensions equal the input dimensions, which surprises people every time. Small pack, zero community footprint, but for fixed-canvas panel merges it's genuinely handy - just come in knowing it slices rather than stacks.
Inputs (7)
| Name | Type | Default | Description |
|---|---|---|---|
| merge_type | COMBO | 左右 | 3 options: 上下, 左右, 平行四边形 |
| image | IMAGE | — | |
| image2 | IMAGE | — | |
| image3opt | IMAGE | — | |
| image4opt | IMAGE | — | |
| image5opt | IMAGE | — | |
| image6opt | IMAGE | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| result_img | IMAGE | — |