🔥ImagePath2Tensor
Bridge file paths into ComfyUI's IMAGE space
- image_paths
- image
- image_count
ImagePath2Tensor is the node that finally gets your files into ComfyUI's image space. The auxiliary chain up to now - LoadImageFromDir, ImageCopy - has been moving paths around. This one decodes the actual images and returns a real IMAGE tensor, which is the currency every ComfyUI image processor (KSampler, VAE, ControlNet, the works) expects. It's the missing link that turns "I have a folder of frames on disk" into "I can run these through my whole img2img pipeline."
How it works
For each path in the input list, it opens the image with PIL (ImageOps.exif_transpose to respect orientation), converts to RGB, and normalizes to a float tensor. Then it stacks them into a single batch tensor along the first dimension - so N images become one IMAGE with batch size N, which is exactly what nodes like KSampler batch-process. Two defensive details: images that fail to open are skipped (with a console warning) rather than killing the graph, and if the images have mismatched sizes, the smaller ones are bilinear-upscaled to match the first image's dimensions so the batch can still stack. That auto-resize is either a lifesaver or a silent quality gotcha depending on how different your frames are.
The inputs that matter
- image_paths - a list of file paths, any-type input. Wire it from LoadImageFromDir's
image_pathsoutput. Feed it raw and it'll error - this expects a list.
Outputs
image- the stackedIMAGEtensor, ready for any image node.image_count- how many images actually made it into the batch (skipped failures don't count).
Install
Part of the ComfyUI-FFmpeg pack's auxiliary set. ComfyUI Manager → search "ComfyUI-FFmpeg", or:
cd ComfyUI/custom_nodes
git clone https://github.com/MoonHugo/ComfyUI-FFmpeg
cd ComfyUI-FFmpeg
pip install -r requirements.txt
Restart ComfyUI.
Gotchas
- Mismatched image sizes get silently stretched to match the first image - a 640×640 frame mixed with 512×512 frames gets upscaled, blurring it. For frame sequences that came from one Video2Frames run, sizes match and you're fine. For mixed sources, normalize sizes yourself first.
- The whole batch lives in GPU/CPU memory at once. A thousand 4K frames as a single tensor is a memory event. If you get OOM, split the list (LoadImageFromDir's
lengthparam) and process in chunks. - The pack flushes ComfyUI's model cache after running (
clear_memory), which is fine on a one-shot graph but slightly rude if you're mid-pipeline - expect a short reload before the next node.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| image_paths | * | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| image | IMAGE | — |
| image_count | INT | — |