How raykosan/comfyui_raykostudio works
Purpose and Host Integration
ComfyUI_RaykoStudio is a Python custom-node extension for ComfyUI, focused on interactive image editing, masking, compositing, prompt/model management, latent preparation, and workflow-aware export. It is installed under ComfyUI’s custom_nodes directory and runs inside ComfyUI’s Python server plus browser canvas runtime. Node registration and extension loading originate at __init__.py; server-side settings endpoints are implemented in settings_manager_api.py.
Extension Architecture
The repository is organized as mostly independent Python node implementations paired with optional browser-side custom widgets. Python nodes consume and produce ComfyUI-native values such as IMAGE tensors, MASK, LATENT, CONDITIONING, MODEL, CLIP, and VAE; frontend modules render controls and synchronize node/widget state through ComfyUI. Key pairing examples:
• Interactive collage: Rayko_Collage.py + web/rs_collage.js
• Interactive outpainting: Rayko_Outpaint.py + web/rs_outpaint.js
• Image adjustments: Rayko_Adjustments.py + web/rs_adjustments.js
Interactive Editing and Queue-Gating Nodes
A defining capability is nodes that pause ComfyUI workflow execution until the user accepts or cancels an edit. These bridge backend processing with persistent frontend editing state and require heartbeat/cleanup behavior to avoid stalled queues.
• Cropping and reinsertion: Rayko_Crop_Image.py, Rayko_Insert_Crop.py, web/rs_crop.js
• Spline mask workflows: Rayko_Spline_Mask.py, Rayko_Intermediate_Spline_Mask.py, web/spline_mask.js
• Batch image selection: Rayko_Image_Selector.py, web/image_selector.js
• Canvas-based compositing/outpainting: Rayko_Collage.py, Rayko_Outpaint.py, web/rs_outpaint.js
Control flow is: image tensor enters node → backend exposes preview/result state → browser collects edits/approval → backend resumes and emits transformed image, mask, dimensions, or crop metadata.
Image Processing, Composition, and Export
Core image-oriented nodes handle alpha preservation, transforms, visual comparison, text rendering, adjustments, and workflow-preserving output.
• Adjustment and color pipeline: Rayko_Adjustments.py, Rayko_Color_Picker.py, Rayko_RGB2RGBA.py
• Text and image composition: Rayko_Text_Overlay_Pro.py, Rayko_Image_Text .py, Rayko_Collage.py
• Output/persistence: Rayko_Save_Image.py, Rayko_Save_Image_Pair.py
• Input and batch ingestion: Rayko_Load_Images_From_Dir.py, Rayko_Spline_Mask.py
The runtime uses Torch tensors, Pillow, NumPy, OpenCV, SciPy, FreeType, and Cairo. Rayko_Text_Overlay_Pro.py uses bundled font assets under fonts/ for server-side high-quality rendering.
Generative Model and Latent Pipeline
Model-facing nodes prepare ComfyUI generation inputs rather than running a standalone inference service.
• Unified model/LoRA loading: Rayko_Models_Loader.py, Rayko_LoRA Loader.py
• Image/reference encoding: Rayko_Image_To_Latent.py, Rayko_Ref2Latent.py
• Empty latent construction: Rayko_MultiLatent.py
• Prompt and style construction: Rayko_Prompts.py, Rayko_Styles_Loader.py
These components load ComfyUI-managed UNET/CLIP/VAE/LoRA assets, encode images via a supplied VAE, and pass latents or modified conditioning downstream to samplers. Styles are repository data in styles/; custom fonts are data in fonts/.
Workflow Control and UI Extensions
Graph-level orchestration is implemented through specialized nodes and frontend behavior:
• Dynamic type-agnostic routing: Rayko_Any_Switch.py, web/rs_any_switch.js
• Bypass management: Rayko_Bypass.py, web/rs_bypass.js
• Iterative integer sequencing: Rayko_Loop_Switch.py, web/loopSwitchSeed.js
• Settings backup/restore extension: settings_manager_api.py, web/settings_manager.js
The settings manager is distinct from node execution: it accesses ComfyUI interface settings, stores backups outside the repository/ComfyUI tree, and can restart the Python server via server-side process control.
External Boundaries and Assets
The primary infrastructure dependency is a compatible ComfyUI installation with Python, Torch, and CUDA-capable execution where applicable. Browser-side JavaScript relies on ComfyUI’s frontend APIs and browser permissions for file/clipboard interactions. LoRA/model metadata can be fetched from the external Civitai API and cached locally by the model-loading nodes. Example workflows are distributable ComfyUI JSON graphs under Example/, including Example/RS Collage.json and Example/RS Outpaint New.json.
Main entry points: __init__.py Extension registration · Rayko_Crop_Image.py Queue-gated editing nodes · Rayko_Adjustments.py Image processing · rs_crop.js Editing widgets
Components 22
ComfyUI Host
- ComfyUI server & canvas · Hosts Python nodes and browser extensions.
- Extension registration · Registers RaykoStudio nodes and web extensions.
__init__.py - ComfyUI native values · IMAGE, MASK, LATENT, CONDITIONING, MODEL, CLIP, and VAE values.
Interactive Editing
- Queue-gated editing nodes · Pause execution for crop, spline mask, selection, collage, and outpaint approval.
Rayko_Crop_Image.py - Crop reinsertion · Reinserts accepted crop results and metadata.
Rayko_Insert_Crop.py - Editing widgets · Canvas editors synchronize persistent edit state and approval.
web/rs_crop.js - Collage compositor · Canvas-based image composition backend.
Rayko_Collage.py - Outpaint widget · Collects canvas outpainting edits.
web/rs_outpaint.js
Generation Inputs
- Model & LoRA loader · Loads ComfyUI-managed UNET, CLIP, VAE, and LoRA assets.
Rayko_Models_Loader.py - Civitai API · Provides model and LoRA metadata for local caching.
- Prompts & styles · Builds prompts, styles, and conditioning.
Rayko_Prompts.py - Style data
- Latent preparation · Encodes references or constructs empty latents for downstream samplers.
Rayko_Image_To_Latent.py
Image Output
- Image processing · Adjustments, alpha/color conversion, text, and comparison operations.
Rayko_Adjustments.py - Bundled fonts · Used for server-side high-quality text rendering.
- Image ingestion · Loads directory batches and source images.
Rayko_Load_Images_From_Dir.py - Image export · Persists images and paired outputs while preserving workflow context.
Rayko_Save_Image.py
Workflow Control
- Routing & bypass nodes · Provides dynamic routing, bypassing, and iterative sequencing.
Rayko_Any_Switch.py - Workflow widgets · Adds switch, bypass, and loop behavior to the canvas.
web/rs_any_switch.js - Settings manager API · Backs up and restores interface settings and can restart the server.
settings_manager_api.py - Settings manager UI
web/settings_manager.js - Example workflows · Distributable collage and outpaint workflow examples.
Connections 27
- ComfyUI server & canvas → Extension registration: loads
- Extension registration → Queue-gated editing nodes: registers
- Extension registration → Image processing: registers
- Extension registration → Model & LoRA loader: registers
- Extension registration → Routing & bypass nodes: registers
- Extension registration → Settings manager API: exposes
- ComfyUI server & canvas → Editing widgets: loads frontend extension
- ComfyUI server & canvas → Workflow widgets: loads frontend extension
- ComfyUI server & canvas → Settings manager UI: loads frontend extension
- ComfyUI native values → Queue-gated editing nodes: image and mask inputs
- Queue-gated editing nodes → Editing widgets: preview, edit state, approval
- Editing widgets → Queue-gated editing nodes: accepted edits
- Queue-gated editing nodes → Crop reinsertion: crop metadata and result
- Collage compositor → Outpaint widget: canvas editing flow
- ComfyUI native values → Image processing: image tensors
- Bundled fonts → Image processing: text rendering fonts
- Image ingestion → Image processing: source images
- Image processing → Image export: composited images
- Model & LoRA loader → ComfyUI native values: MODEL, CLIP, VAE
- Civitai API → Model & LoRA loader: metadata
- Style data → Prompts & styles: style definitions
- Prompts & styles → ComfyUI native values: conditioning
- ComfyUI native values → Latent preparation: images and VAE
- Latent preparation → ComfyUI native values: latents
- Workflow widgets → Routing & bypass nodes: widget state
- Settings manager UI → Settings manager API: backup and restore requests
- Example workflows → Collage compositor: demonstrates