Nodes/comfyui-magic-hour/Magic Hour: Head Swap
ComfyUI Node

Magic Hour: Head Swap

Magic Hour: Head Swap

By magichourhq·Created about 17 hours ago·Updated about 16 hours ago· 0
Magic Hour: Head Swap
  • body
  • head
  • image
  • image_paths
  • credits_charged
◄max_resolution0►

Head Swap is exactly what it says, with no cleverness layered on top: put the head from one photo onto the body in another. Two IMAGE inputs, one INT, one output.

What makes it interesting is that it's the opposite of the same pack's Body Swap. Body Swap puts a whole person into a scene. Head Swap takes a whole person and replaces the top of them. The interesting cases are the ones you'd otherwise fix by hand in Photoshop: the good group photo where one person blinked, the body shot with a decent pose and a bad expression, the era-appropriate costume photo where the face has to be yours.

How it works

Both images become temp PNGs and are uploaded together - body as the body asset, head as the head asset. The remote model segments the head from the second image, matches scale and skin tone to the first, and composites. The result is downloaded into ComfyUI/output/magic_hour/ and handed back as an IMAGE.

Two hard limits worth stating up front, both from the source. First, only the first image of a batch is used for each input, so a batch of poses gets you one result. Second, there is no mask input and no way to specify where the head goes - it finds the neck. That's convenient until it guesses wrong.

The max_resolution field

max_resolution is an INT from 0 to 2048, defaulting to 0. The tooltip is the important bit: 0 = your plan's maximum. Zero isn't "no limit" and it isn't "the smallest" - it's "whatever your account is allowed", which is why the same node can produce a beautiful 4K composite for one person and a soft 640px one for another with identical settings.

Set it explicitly when you care about cost, or when you want deterministic output. The node only sends the parameter when the value is above zero, so leaving it at 0 keeps the request clean and lets the server decide. For a first attempt, put something modest in there (say 1024) and look at the result before you go up - a high ceiling doesn't improve the compositing, it just makes the failings bigger.

Inputs and outputs

| field | what it is | | --- | --- | | body (required) | the image whose body survives. Shoulders visible, neck not covered by a scarf or hair | | head (required) | the image the head comes from. Front-on, neutral expression, similar lighting direction | | max_resolution (required, INT) | 0–2048, 0 = plan maximum |

Outputs: image (the IMAGE result - one frame, or one per returned file), image_paths (STRING with the saved path, newline-joined when multiple), credits_charged (INT).

Install

cd ComfyUI/custom_nodes
git clone https://github.com/magichourhq/comfyui-magic-hour
pip install -r comfyui-magic-hour/requirements.txt

Restart, and find it under Magic Hour. Dependencies: magic-hour>=0.87.1, and that's the entire list - no insightface, no swap model to download, no GPU involved. ComfyUI Manager users can search "Magic Hour".

export MAGIC_HOUR_API_KEY=your_key_here

before you launch ComfyUI, or drop the bare key into comfyui-magic-hour/api_key.txt. Deliberately not a node widget: widget values are saved into the workflow file and leak with it.

What actually goes wrong

Skin tone and lighting mismatch. Two photos taken in different rooms is the default situation and the seam is usually visible at the neck. Matching the light direction is worth more than any setting here - both photos lit from the left beats both photos looking nice.

Hair. Long hair, curls, anything crossing the shoulder line is where head swaps fail, because the boundary isn't a clean ellipse. Short, tidy hair composites well.

Angle mismatch. A profile head on a front-facing body is a hard problem and the model will attempt it anyway. Keep the two roughly aligned.

Neck proportions. A big head on a narrow neck is the classic uncanny tell. If it looks off at max_resolution 1024, it'll look just as off at 2048 with more pixels.

402 mid-run. Credits or plan limits; Magic Hour's own error text comes through in the node so you can tell the difference between "out of credits" and "this size needs a paid plan".

Consent, again. The node description carries the author's note and it's not boilerplate: only use photos you have the right to use. Splicing a real person's head onto a body they never posed for is the case everyone means when they say this.

If the head and the body are of the same person and you just want the best result, this is a better tool than local inpainting for the specific job - the composite is one step instead of four. If they're different people, no tool makes that a good idea.

CategoryMagic Hour

Inputs (3)

NameTypeDefaultDescription
bodyIMAGE—
headIMAGE—
max_resolutionINT00–20480 = your plan's maximum

Outputs (3)

NameTypeDescription
imageIMAGE—
image_pathsSTRING—
credits_chargedINT—