Image Change DType
Force an Image Tensor Into a Specific Precision
- image
- image
This one's plumbing, not creative control - but it's the kind of plumbing that saves you from a cryptic crash. ComfyUI images are tensors under the hood, and tensors carry a data type (dtype): how many bits per number, and whether it's the full-precision float32 or one of the half-precision flavors, float16 or bfloat16. Most of the time ComfyUI and its nodes keep everyone on the same page automatically. Occasionally - mixing a custom node built for one precision with a pipeline running another, or feeding an image loaded at one precision into a model expecting a different one - they don't, and you get a dtype-mismatch error instead of an image. Image Change DType exists to force the issue: cast the tensor to whatever precision you actually need before it hits the node that's picky about it.
The interface is deliberately small: image in, and a dtype dropdown with four choices - default (leave it alone, useful as a documented no-op or a placeholder while you're wiring), float32 (full precision, most memory, safest for numerical accuracy), float16 (half the memory of float32, the standard choice for GPU inference), and bfloat16 (also half-size, different bit layout that trades some precision for a wider numeric range - the one you'll want if a downstream node specifically asks for it, since float16 and bfloat16 aren't interchangeable at the byte level even though they're the same size). Output is image, same tensor, new dtype.
In practice you reach for this when something downstream throws a dtype error and you don't want to chase it back through your whole graph to find where the mismatch was introduced - you just insert this node right before the node that's complaining and set it to whatever that node wants. It's a patch, not a redesign, which is exactly what you want for a one-off compatibility problem instead of restructuring your workflow.
Installing it: this ships in comfyui-mask-util, a small utility pack from longgui0318 - the same author behind comfyui-magic-clothing, a virtual-try-on node that had a short-lived spike of Reddit interest in 2024 and hasn't come up in community discussion since. Mask-util looks like the general glue that got split out of that bigger project: device/dtype casting, crop math, mask bookkeeping. The GitHub README is just the project title with no body text, so there's no official install or usage doc to lean on - everything here comes from the node's own input/output definition.
Install it through ComfyUI Manager (search "comfyui-mask-util") or by hand:
cd ComfyUI/custom_nodes
git clone https://github.com/longgui0318/comfyui-mask-util
Restart ComfyUI afterward. No models, no heavyweight dependencies - a dtype cast is a single .to() call away, so this is about as light as a custom node gets.
Where it bites: casting down to float16 or bfloat16 isn't free - you're throwing away precision, and on an image that's already been through several lossy operations (VAE cycles, repeated resizes) you can start to see banding or subtle artifacting if you stack casts carelessly. And going the other way, forcing float32 on a large image adds real VRAM overhead you may not have budgeted for. If you don't have a concrete error telling you to change precision, you probably don't need this node at all - it's a fix for a specific mismatch, not something to sprinkle in preemptively.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| dtype | COMBO | 4 options: default, float32, float16, bfloat16 |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| image | IMAGE | — |