AIHub Action New Layer
Dropping a generated image onto the editor's canvas as a real layer
- image
- mask
- IMAGE
- MASK
AIHub Action New Layer is the action node that understands the client has a canvas with layers. Instead of just handing an image back like AIHub Action New Image does, it tells the image editor to create a layer - positioned at an X/Y coordinate, inserted before or after a specific existing layer, with a name that shows up in the layer list. This is the node that makes "AI as an inpainting or compositing tool inside your editor" workflows work: you generate a patch in ComfyUI and it arrives in the editor already aligned with everything else.
Pack context, once: otavanopisto's ComfyUI-aihub-workflow-exposer is the bridge that lets external apps run ComfyUI as their engine. Expose nodes pull data in from the client (including the current layer, its position, and its mask - that's where your pos_x/pos_y come from), and action nodes like this one push results back over the pack's own websocket (port 8111). The whole design revolves around the layer metaphor of a real image editor.
How it works
Same encode pipeline as New Image - tensor to PNG, mask folded into the alpha channel - but the websocket event is NEW_LAYER, and the envelope carries pos_x, pos_y, reference_layer_id, and reference_layer_action. The client receives both the image data and the placement instruction, then builds the layer in its own stack. The __first__ and __last__ special values for reference_layer_id let you pin a layer to the top or bottom of the stack without knowing the client's internal ids.
The inputs that matter
- image (required) - what becomes the layer.
- pos_x, pos_y - canvas coordinates for the layer. In a typical workflow these come from an AIHub Expose Image node's
POS_X/POS_Youtputs, so the generated result lands exactly where the source layer was. - reference_layer_id - the layer to position against;
__first__and__last__are the handy shortcuts. - reference_layer_action -
NEW_AFTER,NEW_BEFORE, orREPLACE. Replace swaps out the referenced layer's content, which is the natural choice for "regenerate this layer in place." - action - the filesystem-level
APPEND/REPLACEfor the stored file. The tooltip is worth quoting: since layers are meant to be integrated into the project,REPLACEis often right - the client may delete the old file later anyway. - mask (optional) - alpha for the layer, e.g. a soft-edged inpaint region.
- name - the layer's label in the editor's layer panel.
It echoes IMAGE and MASK back; the real work is the side effect.
Installing it
ComfyUI Manager (search "ComfyUI-aihub-workflow-exposer"), or:
cd ComfyUI/custom_nodes
git clone https://github.com/otavanopisto/ComfyUI-aihub-workflow-exposer
# restart ComfyUI
No requirements, no downloads - it uses ComfyUI's own Pillow/torch stack.
Where people get burned
Position mismatches are the classic annoyance: if the coordinates come from a source image exposed in a different mode than the one your editor supports (see the many type options on Expose Image), your layer lands offset from where you expect. Trace where pos_x/pos_y originate before blaming the node. And the pack-wide rule applies - no aihub client connected means the layer is created nowhere, so a "nothing happened" run is a connection problem, not a node problem.
Inputs (9)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| pos_x | INT | 0 | The X position of the layer in the canvas |
| pos_y | INT | 0 | The Y position of the layer in the canvas |
| reference_layer_id | STRING | The Layer ID regarding the position of the image, the meta-values __first__ and __last__ can be used to refer to the first and last layer respectively | |
| reference_layer_action | COMBO | NEW_AFTER | Specify the action to execute at the given layer id |
| name | STRING | new layer | The name of the layer this is used for the layer list in the UI |
| action | COMBO | REPLACE | This refers to the file system level action, if append is selected, if the image exist it will be added a number to the name to make it unique, if replace is selected, the image will be replaced with the new one; since layers are supposed to be integrated in the project REPLACE is often best |
| maskopt | MASK | — | |
| file_nameopt | STRING | The filename to use, if not given the name value will be used with a .png extension |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| IMAGE | IMAGE | — |
| MASK | MASK | — |