Nodes/Eagleshadow Custom Nodes/Image Linear Gamma Composite Masked
ComfyUI Node

Image Linear Gamma Composite Masked

Image Linear Gamma Composite Masked – ComfyUI Node Guide

By Shadetail·Created 2 years ago·Updated about a year ago· 6
Image Linear Gamma Composite Masked
  • layer_1
  • layer_0
  • mask
  • IMAGE
x0
y0
resize_layer_1false

What it is

Pasting one image on top of another sounds trivial, but do it the naive way and you'll notice the seam - mid-tones near the edge of the pasted layer look muddier or darker than they should, especially with soft masks. That's a gamma problem: image files are stored gamma-encoded (roughly, the sRGB curve your monitor and file formats assume), and blending two gamma-encoded images directly doesn't match how light actually mixes. Every serious compositing tool - Photoshop, Nuke, After Effects - converts to linear light before blending and converts back afterward. Image Linear Gamma Composite Masked does exactly that inside ComfyUI: it composites two images, converting to linear space first and back to gamma space after, so the blend actually looks correct instead of subtly wrong.

Reach for it any time you're pasting one image onto another with a soft or partial mask - compositing a generated subject over a background, layering elements with feathered edges - and you're seeing muddy or darkened blend seams with the standard approach.

How it works

You give it two layers, a position to place the top one, and an optional mask to control exactly which pixels of the top layer actually land. Internally it converts both images out of gamma space into linear light, does the actual blending math there (this is where masked alpha compositing behaves correctly), then converts the result back to gamma space for you to save or continue working with. It'll also optionally resize the top layer to fit, rather than requiring you to pre-resize it yourself.

Inputs that matter

  • layer_0 – your base/background image.
  • layer_1 – the image being placed on top. Note the node lists layer_1 before layer_0 in its widget order, so don't assume the first field you see is the background - check the label.
  • x, y (INT, 0–16384, default 0) – where to place the top layer's origin on the base image.
  • resize_layer_1 (BOOLEAN, default false) – resize the top layer to fit rather than pasting it at native size.
  • mask (optional MASK) – controls which parts of the top layer actually composite in. Leave it unwired and you get a full rectangular paste; wire in a soft-edged mask (this pack's own MaskGlow is a natural partner here) and you get a proper feathered blend.

Output

One IMAGE: the composited result, gamma-corrected back to normal so it's ready to save or feed into the next step.

Installing it

Bundled with the rest of the pack:

cd ComfyUI/custom_nodes
git clone https://github.com/Shadetail/ComfyUI_Eagleshadow

Or install "Eagleshadow Custom Nodes" via ComfyUI Manager. No model downloads, no heavy dependencies.

Common issues

Double-check which input is which. Because layer_1 appears first in the schema and layer_0 second, it's easy to wire your background into layer_1 by accident, especially if you're used to "first input = base" conventions from other compositing nodes. If your top layer is inexplicably behind the base image, swap them.

Placement is by top-left origin, not centered. x and y position the top layer's corner, not its center - if you're expecting a centered paste, do the offset math yourself (base dimensions minus top-layer dimensions, divided by two) before feeding in x/y.

Without a mask, you get a hard rectangular paste. The gamma correction fixes color blending quality, not edge softness - if you want a feathered blend rather than a sharp rectangle, you still need to wire in a mask. It won't infer softness on its own.

Categoryimage

Inputs (6)

NameTypeDefaultDescription
layer_1IMAGE
layer_0IMAGE
xINT00–16384
yINT00–16384
resize_layer_1BOOLEANfalse
maskoptMASK

Outputs (1)

NameTypeDescription
IMAGEIMAGE