ComfyUI-Mircify

A ComfyUI custom node for converting images into IRC art by processing them in pixel blocks and generating both image and text outputs with optimal color selection from a 99-color IRC palette.

This node is used with aibird to convert images to IRC art.

Workflow Example

Workflow

An example workflow is provided in workflows/mircify_example_workflow.json. At the moment this example is using qwen image lightning, however any model that is decent at making pixel ansi style art can suffice.

Features

  • Universal Image Support: Works with any image dimensions
  • Color Transfer Integration: Uses KMeans clustering with multiple distance methods for accurate color mapping
  • Block Processing: Configurable block sizes (default 8x15 pixels)
  • Half Block Mode: Option for 8x7.5 pixel blocks for finer resolution
  • Dominant Color Extraction: Uses k-means clustering to find the most prominent color in each block
  • Multiple Distance Methods: Choose between weighted manhattan, manhattan, euclidean, and perceptual weighted distance calculations
  • 99-Color IRC Palette: Maps colors to extended IRC color palette
  • 16-Color Compatibility Mode: Option to use traditional 16-color IRC palette
  • Dual Output: Returns both processed image and mIRC-formatted text
  • Optimized Text Output: Compressed color codes and space-efficient formatting
  • Text File Export: Save IRC codes directly to text files with timestamp support

Installation

  1. Clone or download this repository to your ComfyUI custom_nodes directory:

    cd ComfyUI/custom_nodes
    git clone https://github.com/birdneststream/ComfyUI-Mircify
    
  2. Install dependencies:

    cd ComfyUI-Mircify
    pip install -r requirements.txt
    
  3. Restart ComfyUI

Nodes

IRC Art Converter

Category: image/conversion

Converts images into IRC art with both visual and text output.

Inputs:

  • image: Input image (any dimensions supported)
  • block_width: Width of each block in pixels (default: 8)
  • block_height: Height of each block in pixels (default: 15)
  • half_block_mode: Enable half-height blocks (8x7.5 instead of 8x15)
  • use_16_colors: Use only first 16 IRC colors for compatibility (default: False)
  • distance_method: Color distance calculation method (weighted_manhattan/manhattan/euclidean/perceptual_weighted)

Outputs:

  • processed_image: Visual representation of the IRC art conversion
  • irc_text: mIRC-formatted text with color codes ready for IRC clients

IRC Text Saver (still not working too good with color matching)

Category: text/output

Saves IRC-formatted text to files for easy copying.

Inputs:

  • irc_text: IRC text from the converter (STRING input)
  • filename: Output filename with {TIMESTAMP} placeholder support (default: "irc_art.txt")

Outputs:

  • file_path: Absolute path to the saved file

Usage

  1. Basic Workflow:

    • Load an image
    • Connect it to "IRC Art Converter"
    • Connect the irc_text output to "IRC Text Saver"
    • Run the workflow
  2. Distance Methods:

    • weighted_manhattan: Manhattan distance with perceptual weights (Green=1.0, Red=0.7, Blue=0.5) for better natural color matching
    • manhattan: Standard Manhattan distance (L1 norm) - fastest calculation
    • euclidean: Standard Euclidean distance (L2 norm) - geometric accuracy
    • perceptual_weighted: Euclidean distance with CIE luminance weights for perceived brightness matching
  3. Block Modes:

    • Full blocks (8x15): Standard IRC character block size
    • Half blocks (8x7.5): Provides finer vertical resolution
  4. Color Modes:

    • 99-color mode: Full extended IRC palette for maximum color accuracy
    • 16-color mode: Traditional IRC colors for better compatibility
  5. Text Output:

    • Uses optimized mIRC color text output
    • Ready to paste directly into IRC clients
    • Support for {TIMESTAMP} placeholder in filenames

Color Processing

The node uses a two-stage approach:

  1. Color Transfer Phase: Applies KMeans clustering with configurable distance methods to map the entire image to the 99-color IRC palette
  2. Block Processing Phase: Divides the color-corrected image into blocks using dominant color extraction and generates the final IRC art output

IRC Color Palette

The node uses an extended 99-color IRC palette built in. It also can support just 16 colors.

For more information about how IRC uses colors refer to these resources:

Requirements

  • ComfyUI
  • Python 3.8+
  • torch
  • numpy
  • scikit-learn
  • pillow

Credits

  • Color transfer logic adapted from ComfyUI-Color_Transfer by 45uee
  • Uses KMeans clustering with modified multiple distance methods for optimal color mapping

License

MIT License

S
Description
No description provided
Readme
556 KiB
Languages
Python 100%