Img2Img
One node for txt2img and img2img — and it hands you the filename too
- vae
- empty_latent
- boolean
- IMAGE
- MASK
- latent
- filename
- cleaned filename
- width
- height
- denoise strength
If you've rebuilt the txt2img → img2img switch more times than you can count - toggle the image loader, swap in a resize, remember which denoise goes where - AUNImg2Img exists to retire that subgraph. It's the whole "load a reference, resize it, encode it to latent" routine in a single node, with a boolean that flips between full txt2img and img2img modes without you rewiring anything. It's part of the AUN pack's all-in-one philosophy: fewer nodes, cleaner graphs, filenames that actually flow downstream.
How it works
The mechanism is the same dance every img2img workflow does, just packaged. Flip img2img on and the node opens your image, resizes it so the longest side matches your new_width / new_height (aspect ratio preserved, Lanczos resampling), then encodes it to latent space with the VAE you feed in. That latent is what your KSampler denoises. Flip it off and it ignores the image entirely, passes your empty_latent straight through, and pins denoise to 1.0 - a clean txt2img start.
A couple of details worth knowing before you wire it up:
latent_widthandlatent_heightare connections, not widgets. They come from your Empty Latent node so the node always knows what resolution the sampler expects.- It returns the actual
width/heightit computed after resizing, and thedenoise strengthit used. Wire those into your KSampler (or a text node) and the filename and the sampling stay in sync automatically.
Inputs and outputs that matter
For a beginner the inputs to actually touch: img2img (the mode toggle), image (the reference you upload), denoise_strength, new_width/new_height, and vae + empty_latent which you wire in from a VAE Loader and Empty Latent.
Outputs, in the order you'll use them:
latent- goes to your KSampler's latent input. This is the point of the node.IMAGEandMASK- the loaded/resized image and its alpha as a mask (all ones if the image has no alpha).boolean- mirrors theimg2imgflag, handy for driving a switch elsewhere.filenameandcleaned filename- the source filename, optionally word-capped bymax_num_words. The cleaned version is the one you want in prompts or save paths.
Installing it
AUN is one pack with all of these nodes, so you install it once:
- ComfyUI Manager (recommended): search for "AUN ComfyUI Nodes" and install, then restart ComfyUI.
- Manual: from your ComfyUI folder,
cd custom_nodes && git clone https://github.com/loz2754/AUN-ComfyUI-Nodes, then restart.
The pack's requirements.txt pulls in piexif, opencv-python-headless, imageio-ffmpeg, and requests. Manager handles these automatically; if you cloned by hand and hit ModuleNotFoundError: cv2 or piexif, run pip install -r custom_nodes/AUN-ComfyUI-Nodes/requirements.txt.
Common issues
The one I keep seeing: people expect new_width/new_height to be used in txt2img mode too. They're not - that's what empty_latent is for. If you flip the mode and your image comes back huge or tiny, check that your Empty Latent is set where you want the final canvas, because in img2img mode the node resizes to your new_ values, not to the latent. And remember img2img only preserves general layout, not your exact subject - same as every non-ControlNet img2img, just faster to set up here.
Inputs (10)
| Name | Type | Default | Description |
|---|---|---|---|
| img2img | BOOLEAN | false | Enable/disable Img2Img mode. |
| denoise_strength | FLOAT | 1.000–1 | Set the denoise strength for Img2Img. |
| new_width | INT | 10240–2048 | Set the new width for the image when Img2Img is enabled. The longest side of the image will be resized to this length. Aspect ratio is preserved. |
| new_height | INT | 10240–2048 | Set the new height for the image when Img2Img is enabled. The longest side of the image will be resized to this length. Aspect ratio is preserved. |
| latent_width | INT | The width of the latent space (from EmptyLatentImage node). The longest side of the image will be resized to this length. Aspect ratio is preserved. | |
| latent_height | INT | The height of the latent space (from EmptyLatentImage node). The longest side of the image will be resized to this length. Aspect ratio is preserved. | |
| image | COMBO | Select the image to use for Img2Img. | |
| max_num_words | INT | 00–32 | Maximum number of words to keep for both filename outputs. Set to 0 for no limit. |
| vae | VAE | The VAE to use for encoding the image to latent space. | |
| empty_latent | LATENT | The empty latent image to use when Img2Img is disabled. |
Outputs (9)
| Name | Type | Description |
|---|---|---|
| boolean | BOOLEAN | — |
| IMAGE | IMAGE | — |
| MASK | MASK | — |
| latent | LATENT | — |
| filename | STRING | — |
| cleaned filename | STRING | — |
| width | INT | — |
| height | INT | — |
| denoise strength | FLOAT | — |