PIL To Image
Convert a Pillow image back into ComfyUI's native IMAGE type
- images
- IMAGE
PILToImage is ImageToPIL run in reverse: it takes a PIL.Image object and hands back ComfyUI's native IMAGE tensor - the type every stock node in ComfyUI (Save Image, Preview Image, VAE Encode, every sampler) actually expects. If you've done anything with a raw Pillow object and need it to rejoin the rest of your graph, this is the node that lets it back in.
In practice that "anything" is almost always one of two situations. The common one is scripting a workflow through ComfyScript, the same author's Python front-end for ComfyUI: in its "real mode," steps run as actual Python objects rather than as a node graph, so if a step in your script does PIL-native work - drawing text, reading EXIF, palette manipulation, anything easier to express with Pillow's own API than with a tensor - you'll have a PIL.Image sitting in your script by the time you want to hand it back to a ComfyUI-shaped pipeline. PILToImage is the handoff. The less common but real case: some other custom node pack outputs a PIL_IMAGE because its own logic is Pillow-based, and you need a normal IMAGE to keep going - this node is the adapter regardless of which pack produced the PIL object.
If neither of those describes what you're doing, you probably don't need this node. There's no reason to route a normal image through PIL and back for no purpose - it just adds an unnecessary conversion.
The inputs and outputs that matter
- images (PIL_IMAGE) - the only input. It has to come from something that actually outputs
PIL_IMAGE: this pack's ownImageToPIL, or another pack's PIL-flavored node. - Output: IMAGE - the standard ComfyUI image tensor, ready to plug into anything that takes one.
How to install it
Same pack as every node in this family: ComfyUI Manager, search "ComfyUI_Ib_CustomNodes", or manually:
cd ComfyUI/custom_nodes
git clone https://github.com/Chaoses-Ib/ComfyUI_Ib_CustomNodes
then restart. Nothing extra to configure - Pillow's already part of ComfyUI's own dependency set, so installing this pack doesn't pull anything heavy in.
Common issues & troubleshooting
Nothing to plug into the images input. The most common way to land on this node with no clean upstream is misreading what it's for - it doesn't take a normal IMAGE, only PIL_IMAGE. If your source is a regular Load Image node, you don't need this node at all; wire IMAGE straight through.
You expected this to also fix a mask. It doesn't touch masks - for that, see PILToMask, this pack's sibling node, and note that its output is typed IMAGE too rather than MASK (worth reading before assuming it slots straight into an inpaint mask input).
The image looks different after the round trip. Converting through PIL and back is generally lossless for pixel data, but if whatever produced the PIL_IMAGE changed the mode (say, converted to RGBA, palette, or grayscale) before handing it to you, that shows up once it's back as an IMAGE tensor. If colors or channels look wrong, check what mode the PIL object was in right before this node - it's a straight conversion, not a color-management step.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| images | PIL_IMAGE | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| IMAGE | IMAGE | — |