Comfy Pencil Import Layer
Comfy Pencil Import Layer
- document
- image
- mask
- document
- image
- mask
- metadata_json
Comfy Pencil Studio paints; this node feeds it. ComfyPencilImportLayer takes an image from anywhere else in the graph - a fresh generation, a ControlNet preprocess, an upscale, a reference photo - and injects it into a ComfyPencil document as a real layer with its own blend mode, opacity, and position in the stack. Then you open the studio and paint over it, or stack several imports into one layered file.
That's the pattern worth internalizing: generate a base, import it as a layer, hand-paint the fix, send the composite back through the sampler. It turns "paint in another app, import, hope" into a loop that stays entirely inside ComfyUI.
Mechanically it's a straightforward composite. The node takes the IMAGE (plus an optional MASK used as the layer's alpha), converts it to RGBA, resizes it to the document canvas according to resize_mode, and inserts it at the top or bottom of the stack. Then it re-renders the whole document and hands you the result. The persist_to_source toggle (on by default) saves the new layer back to the on-disk document when that document has a stable id, so the import is still there next time you open the studio - not just in the current run.
The inputs that matter:
blend_mode-normal,multiply,screen,overlay,soft-light,add. Multiply is the classic for dropping line art or a texture over a base.resize_mode- this is the one beginners get surprised by.fitletterboxes onto the canvas (centered, with transparency around it),fillscales to cover and crops the overflow,stretchdistorts to fill edge to edge, andcenterdrops the image at its native size in the middle.fitis the safe default;fillis what you want when a generated image must cover the whole canvas.placement-toporbottomof the layer stack.opacity- 0.0 to 1.0.
Outputs are document (the updated PENCIL_DOCUMENT, which you can chain into Render Document or Extract Layer), image and mask (the freshly composited result), and metadata_json with the document summary.
Install is shared with the rest of the pack:
cd ComfyUI/custom_nodes
git clone https://github.com/criskb/Comfypencil ComfyPencil
Restart, hard-refresh the browser, and find it under Comfy Pencil. No models, no keys, no extra Python dependencies - it runs on ComfyUI's bundled torch/Pillow, and targets ComfyUI >= 0.16.0.
Two traps worth knowing. persist_to_source only does anything if the document already has a saved id - a fresh, never-saved doc has nowhere to write, so save or open a project in the studio first if you want the import to stick. And flatten_background only affects this node's image output; it doesn't change the stored layer data, so don't expect it to alter what the studio shows. If you're importing a mask-backed image, that's exactly what the optional mask input is for - wire it in and the mask becomes the layer's alpha instead of a solid rectangle.
Inputs (11)
| Name | Type | Default | Description |
|---|---|---|---|
| document | PENCIL_DOCUMENT | — | |
| image | IMAGE | — | |
| layer_name | STRING | Imported Layer | — |
| blend_mode | COMBO | normal | 6 options: normal, multiply, screen, overlay, soft-light, add |
| opacity | FLOAT | 1.000–1 | — |
| visible | BOOLEAN | true | — |
| placement | COMBO | top | 2 options: top, bottom |
| resize_mode | COMBO | fit | 4 options: fit, fill, stretch, center |
| persist_to_source | BOOLEAN | true | — |
| flatten_background | BOOLEAN | false | — |
| maskopt | MASK | — |
Outputs (4)
| Name | Type | Description |
|---|---|---|
| document | PENCIL_DOCUMENT | — |
| image | IMAGE | — |
| mask | MASK | — |
| metadata_json | STRING | — |