Skip to content

Adding in new Krita Group Layer node#2406

Open
Pauan wants to merge 6 commits intoAcly:mainfrom
Pauan:feat/layer-group
Open

Adding in new Krita Group Layer node#2406
Pauan wants to merge 6 commits intoAcly:mainfrom
Pauan:feat/layer-group

Conversation

@Pauan
Copy link
Copy Markdown

@Pauan Pauan commented Mar 28, 2026

Currently there are three ways to send images to ComfyUI: Krita Canvas, Krita Image Layer, and Krita Mask Layer.

This adds a new Krita Group Layer node that sends an entire group of image layers to ComfyUI (along with the masks and names of each image layer).

This is really useful for a variety of situations:

  • Sending multiple animation frames outside of Generate Animation mode.
  • Sending multiple image masks all at once without needing to send them individually.
  • Processing an entire batch of images at the same time (upscaling, detailing, etc.)

Originally I wanted to add this feature to the existing Krita Image Layer and Krita Mask Layer nodes, but that would have needed significant code refactoring. So I made a new node instead.

@Acly
Copy link
Copy Markdown
Owner

Acly commented Apr 2, 2026

Originally I wanted to add this feature to the existing Krita Image Layer and Krita Mask Layer nodes, but that would have needed significant code refactoring. So I made a new node instead.

I think the following should work:

  • add a "group mode" option to Image Layer / Mask Layer nodes which can be "merged" or "batch"
  • read the group mode from the plugin and maybe put it into CustomParam
  • make collect_parameters return the projection ("merged") or an image collection of child layers ("batch")
  • make the nodes return the image as batch, same as for animation case

Image Layer node should filter image layers and Mask Layer node mask layers, so you might have to use 2 nodes if you have a mixed group. Also no names.

Not sure that fits your use case, but as it is it already feels highly specific to me, and other users are unlikely to discover or understand how to use it with the extra nodes and lists. It would be nice if Comfy had better support for structured data & lists, but as it is, I think keeping it as simple as possible and sticking to batches is better.

@Pauan
Copy link
Copy Markdown
Author

Pauan commented Apr 2, 2026

Also no names.

The names are necessary, they are not optional.

For example, if you want to send regions over to ComfyUI, you need to match the region name with the layer. Or if you're sending masks, you need to match the mask name with the layer.

Sending the names opens up a lot of extra possibilities, which is well worth it.

It would be nice if Comfy had better support for structured data & lists, but as it is, I think keeping it as simple as possible and sticking to batches is better.

ComfyUI's support for data lists is actually pretty robust, and works quite well.

Because the images and names are both a data list, they will be properly zipped together. So everything works as you would expect.

@Pauan
Copy link
Copy Markdown
Author

Pauan commented Apr 2, 2026

add a "group mode" option to Image Layer / Mask Layer nodes which can be "merged" or "batch"

Yes, I originally tried that, but it required a lot of refactoring. I can try it again...

@Acly
Copy link
Copy Markdown
Owner

Acly commented Apr 2, 2026

It should be a small change. I could be wrong, but if it requires lots of refactor / additional code it's probably not worth it.

@Pauan
Copy link
Copy Markdown
Author

Pauan commented Apr 3, 2026

Yeah it ended up being a pretty small change.

However, adding this feature to Krita Mask Layer is more complicated, because it currently only allows you to select transparency / selection layers... not group layers.

So I only made the change to Krita Image Layer for now.

if len(list) == 1:
return list[0]

output = self.add("ETN_ListEmpty", 1)
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does this use custom list nodes?

Can't ComfyUI built-in nodes be used (PrimitiveString, CreateList)?

Comment thread ai_diffusion/workflow.py
img, mask = w.load_image_and_mask(get_param(node, (Image, ImageCollection)))
layer: CustomLayerInput = get_param(node, CustomLayerInput)
img, mask = w.load_image_and_mask(layer.images)
if not layer.is_batch:
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be better to always return a batch. The node output type can stay the same and it's less confusing for flatten/animation. Rebatch can be added in the workflow if a list is needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants