🔍 获取首/末帧图片
Grab the first or last frame of a batch, plus its dimensions
- image_batch
- image
- width
- height
Almost every video or animation workflow eventually asks the same question: what does the first frame look like? The first frame is your thumbnail, your img2img seed, your reference card for an LLM describing the scene. This node, "🔍 获取首/末帧图片", answers it directly - it slices the first (or last) frame out of an IMAGE batch and hands it back as a single-image batch, with the width and height thrown in as a bonus.
How it works
Trivial in the best way: it takes the batch and returns image_batch[0:1] (or image_batch[-1:] if mode is last). The slice keeps the batch dimension - you get a (1, H, W, C) tensor, which is exactly what every node downstream expects, since most ComfyUI nodes refuse plain 3D images. A 3D single image input gets promoted to a batch of one instead of erroring. It also unpacks width and height from the frame's shape while it's in there.
Inputs and outputs
image_batch(IMAGE) - the stack to slice from.mode-firstorlast, defaultfirst.- Outputs:
image(IMAGE) - the single extracted frame;width(INT) andheight(INT) - the frame's dimensions.
Where it fits
The natural wiring in this pack: after SplitVideoByFrames hands you clips, or after any video loader gives you a frame batch, grab the first frame and route it to an img2img node, an image-to-video model, or a captioning LLM. The width/height outputs are the quiet win - instead of dragging a separate Get Image Size node into the graph, you get dimensions for free, which is handy for wiring up size-conditional logic.
One pairing that shows up a lot in batch-assembly loops: GetFirstImageFromBatch to pull the current first frame, and its sibling RemoveFirstOrLastImageFromBatch to drop it - together they let you peel a batch like a deck of cards.
Installing it
Standard pack install - ComfyUI Manager → search comfyUI_LLM, or:
cd ComfyUI/custom_nodes
git clone https://github.com/XieJunchen/comfyUI_LLM
# restart ComfyUI
Pure torch slicing; no extra dependencies.
The edge cases
- Empty batch → hard error. It raises "image_batch is empty!" rather than returning garbage. Fair, but know it's coming if you feed it the output of an empty
CreateEmptyImageBatch. - No
middlemode. Just first and last - if you need the Nth frame,GetVideoClipByIndexor an image-indexing node from the wider ecosystem is your tool.
It's a two-option utility node, and it's fine that it's boring - half the battle in ComfyUI is wrangling batch shapes, and this node removes the fiddliest slice for you.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| image_batch | IMAGE | — | |
| mode | COMBO | first | 2 options: first, last |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| image | IMAGE | — |
| width | INT | — |
| height | INT | — |