mostlylucid.consoleimage 2.3.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package mostlylucid.consoleimage --version 2.3.0
                    
NuGet\Install-Package mostlylucid.consoleimage -Version 2.3.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="mostlylucid.consoleimage" Version="2.3.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="mostlylucid.consoleimage" Version="2.3.0" />
                    
Directory.Packages.props
<PackageReference Include="mostlylucid.consoleimage" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add mostlylucid.consoleimage --version 2.3.0
                    
#r "nuget: mostlylucid.consoleimage, 2.3.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package mostlylucid.consoleimage@2.3.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=mostlylucid.consoleimage&version=2.3.0
                    
Install as a Cake Addin
#tool nuget:?package=mostlylucid.consoleimage&version=2.3.0
                    
Install as a Cake Tool

mostlylucid.consoleimage

Version 2.0 - High-quality ASCII art renderer for .NET 10 using shape-matching algorithm.

NuGet License: Unlicense

Animation

ASCII Mode ColorBlocks Mode Braille Mode
<img src="https://github.com/scottgal/mostlylucid.consoleimage/raw/master/samples/wiggum_ascii.gif" width="200" alt="ASCII"> <img src="https://github.com/scottgal/mostlylucid.consoleimage/raw/master/samples/wiggum_blocks.gif" width="200" alt="Blocks"> <img src="https://github.com/scottgal/mostlylucid.consoleimage/raw/master/samples/wiggum_braille.gif" width="200" alt="Braille">

Note: These images are rendered using the tool's GIF output with a consistent monospace font. Actual terminal display varies by terminal emulator, font, and color support.

Still Images

Landscape Portrait
<img src="https://github.com/scottgal/mostlylucid.consoleimage/raw/master/samples/demo_mountain_blocks.gif" width="280" alt="Mountain"> <img src="https://github.com/scottgal/mostlylucid.consoleimage/raw/master/samples/demo_portrait_blocks.gif" width="200" alt="Portrait">

Quick Start

using ConsoleImage.Core;

// One line - just works!
Console.WriteLine(AsciiArt.Render("photo.jpg"));

// Colored output
Console.WriteLine(AsciiArt.RenderColored("photo.jpg"));

// Play animated GIF
await AsciiArt.PlayGif("animation.gif");

Render Modes

ASCII (Shape-Matched Characters)

<img src="https://github.com/scottgal/mostlylucid.consoleimage/raw/master/samples/wiggum_ascii.gif" width="300" alt="ASCII Mode">

Characters selected by visual shape similarity using 6-point sampling grid.

using var renderer = new AsciiRenderer(new RenderOptions { MaxWidth = 80 });
var frame = renderer.RenderFile("photo.jpg");
Console.WriteLine(frame.ToAnsiString()); // Colored
Console.WriteLine(frame.ToString());      // Plain text

ColorBlocks (Unicode Half-Blocks)

<img src="https://github.com/scottgal/mostlylucid.consoleimage/raw/master/samples/wiggum_blocks.gif" width="300" alt="ColorBlocks Mode">

2x vertical resolution using ▀▄█ characters with 24-bit color.

using var renderer = new ColorBlockRenderer(new RenderOptions { MaxWidth = 80 });
string output = renderer.RenderFile("photo.jpg");
Console.WriteLine(output);

Braille (Ultra-High Resolution)

<img src="https://github.com/scottgal/mostlylucid.consoleimage/raw/master/samples/wiggum_braille.gif" width="300" alt="Braille Mode">

2x4 dots per character cell (8 dots total) for maximum detail. Uses advanced rendering techniques:

  • Autocontrast: Automatically adjusts threshold based on image's actual brightness range (inspired by img2braille)
  • Selective Floyd-Steinberg dithering: Error diffusion only in mid-tone regions for smooth gradients while keeping dark/bright areas clean
  • 24-bit color support: Each braille cell colored with averaged pixel color
using var renderer = new BrailleRenderer(new RenderOptions { MaxWidth = 80 });
string output = renderer.RenderFile("photo.jpg");
Console.WriteLine(output);

Best results with: photographs, gradients, detailed artwork. For line art, consider disabling dithering (EnableDithering = false) for sharper edges.

Terminal Protocols (Native Images)

For terminals that support native image protocols:

using var renderer = new UnifiedRenderer(new RenderOptions { MaxWidth = 80 });

// Auto-detect best protocol
string output = renderer.RenderFile("photo.jpg", TerminalProtocol.Auto);

// Or specify explicitly
string sixel = renderer.RenderFile("photo.jpg", TerminalProtocol.Sixel);
string iterm = renderer.RenderFile("photo.jpg", TerminalProtocol.ITerm2);
string kitty = renderer.RenderFile("photo.jpg", TerminalProtocol.Kitty);

Edge Detection

Enhance foreground visibility with Sobel edge detection:

var options = new RenderOptions
{
    EnableEdgeDetection = true,  // Sobel edge detection
    EnableEdgeDirectionChars = true  // Use /\|- for edge directions
};
using var renderer = new AsciiRenderer(options);
var frame = renderer.RenderFile("photo.jpg");

Edge detection is particularly effective for:

  • Images with complex backgrounds
  • Line art and diagrams
  • Photos where subject separation is important

Contrast and Dithering

Contrast Enhancement

Control contrast with power curve (S-curve):

var options = new RenderOptions
{
    ContrastPower = 2.5f,  // Default. Higher = more contrast
    DirectionalContrastStrength = 0.3f  // Edge emphasis
};
Value Effect
1.0 No enhancement
2.0 Moderate contrast
2.5 Default - good balance
3.0+ High contrast, dramatic

Floyd-Steinberg Dithering

Error-diffusion dithering for smooth gradients:

var options = new RenderOptions
{
    EnableDithering = true  // Default. Smooth gradients
};

Dithering is particularly effective for:

  • Photographs with subtle gradients
  • Skin tones and natural imagery
  • ColorBlocks mode for maximum quality

Background Handling

Automatic Background Suppression

Use manual thresholds for better control over backgrounds:

Manual Threshold Control

Fine-tune for specific images:

var options = new RenderOptions
{
    // For light backgrounds (white, light gray)
    BackgroundThreshold = 0.85f,  // Suppress above this brightness

    // For dark backgrounds (black, dark gray)
    DarkBackgroundThreshold = 0.15f,  // Suppress below this brightness

    // Terminal optimization (skip near-black/white for blending)
    DarkTerminalBrightnessThreshold = 0.1f,
    LightTerminalBrightnessThreshold = 0.9f
};

RenderOptions Reference

var options = new RenderOptions
{
    // Dimensions
    Width = null,                    // Exact width (null = auto)
    Height = null,                   // Exact height (null = auto)
    MaxWidth = 120,                  // Maximum width constraint
    MaxHeight = 40,                  // Maximum height constraint
    CharacterAspectRatio = 0.5f,     // Width/height of terminal chars

    // Appearance
    UseColor = true,                 // Enable ANSI colors
    Invert = true,                   // For dark terminals (default)
    ContrastPower = 2.5f,            // Contrast enhancement (1.0-4.0)
    DirectionalContrastStrength = 0.3f,

    // Character sets
    CharacterSet = null,             // Custom chars (light to dark)
    CharacterSetPreset = "extended", // extended|simple|block|classic

    // Animation
    AnimationSpeedMultiplier = 1.0f,
    LoopCount = 0,                   // 0 = infinite
    FrameSampleRate = 1,             // Skip frames (2 = every 2nd)

    // Features
    EnableDithering = true,          // Floyd-Steinberg dithering
    EnableEdgeDirectionChars = false, // Use /\|- for edges (experimental)
    EnableEdgeDetection = false,      // Sobel edge detection (experimental)
    UseParallelProcessing = true,     // Multi-threaded rendering

    // Background handling (manual thresholds)
    BackgroundThreshold = null,       // Light bg threshold (0-1)
    DarkBackgroundThreshold = null,   // Dark bg threshold (0-1)

    // Terminal optimization
    DarkTerminalBrightnessThreshold = 0.1f,  // Skip very dark colors
    LightTerminalBrightnessThreshold = 0.9f  // Skip very bright colors
};

Presets

var options = RenderOptions.Default;            // Sensible defaults
var options = RenderOptions.HighDetail;         // Maximum quality
var options = RenderOptions.Monochrome;         // No color
var options = RenderOptions.ForLightBackground; // Light terminals
var options = RenderOptions.ForDarkBackground;  // Dark image enhancement
var options = RenderOptions.ForAnimation(loopCount: 3);

Animated GIFs

// Simple playback
await AsciiArt.PlayGif("animation.gif");

// With options
var options = RenderOptions.ForAnimation(loopCount: 3);
options.AnimationSpeedMultiplier = 1.5f;
await AsciiArt.PlayGif("animation.gif", options);

// Manual control
using var renderer = new AsciiRenderer(options);
var frames = renderer.RenderGif("animation.gif");
using var player = new AsciiAnimationPlayer(frames, useColor: true);
await player.PlayAsync(cancellationToken);

// ColorBlocks animation
using var blockRenderer = new ColorBlockRenderer(options);
var blockFrames = blockRenderer.RenderGif("animation.gif");
// frames implement IAnimationFrame for unified handling

GIF Output

Save rendered output as animated GIF:

using var gifWriter = new GifWriter(new GifWriterOptions
{
    FontSize = 10,        // Text size in pixels
    Scale = 1.0f,         // Output scale factor
    MaxColors = 128,      // GIF palette size (16-256)
    LoopCount = 0,        // 0 = infinite loop
    MaxFrames = null,     // Limit frames
    MaxLengthSeconds = null
});

using var renderer = new AsciiRenderer(options);
foreach (var frame in renderer.RenderGif("input.gif"))
{
    gifWriter.AddFrame(frame, frame.DelayMs);
}

await gifWriter.SaveAsync("output.gif");

Loading from URLs

// Download and render
using var stream = await UrlHelper.DownloadAsync(
    "https://example.com/image.jpg",
    (downloaded, total) => Console.Write($"\r{downloaded}/{total}"));

using var renderer = new AsciiRenderer(options);
var frame = renderer.RenderStream(stream);

Windows ANSI Support

// Call once at startup for Windows console ANSI support
ConsoleHelper.EnableAnsiSupport();

Character Set Presets

Preset Characters Description
extended 91 chars Default - maximum detail
simple .:-=+*#%@ Fast, minimal
block ░▒▓█ Unicode density blocks
classic 71 chars Original algorithm set

Terminal Protocol Support

Protocol Terminals Detection
Sixel xterm, mlterm, foot, WezTerm TERM + query
iTerm2 iTerm2, WezTerm, Mintty ITERM_SESSION_ID
Kitty Kitty KITTY_WINDOW_ID
// Check what's supported
var protocol = TerminalCapabilities.DetectBestProtocol();
bool hasSixel = TerminalCapabilities.SupportsSixel();
bool hasKitty = TerminalCapabilities.SupportsKitty();
bool hasITerm = TerminalCapabilities.SupportsITerm2();

Performance

  • SIMD optimized: Vector128/256/512 for distance calculations
  • Parallel processing: Multi-threaded rendering
  • Pre-computed tables: Eliminates trig calls in sampling
  • K-D tree matching: Fast nearest-neighbor in 6D space
  • Result caching: Quantized lookups cached

Attribution

This library implements techniques and algorithms from various sources:

  • ASCII shape-matching: Based on Alex Harri's ASCII rendering approach
  • Braille autocontrast: Inspired by img2braille
  • Floyd-Steinberg dithering: Classic error-diffusion algorithm for smooth gradients
  • Braille Unicode mapping: Standard Unicode Braille Patterns block (U+2800-U+28FF)

License

Public domain - see UNLICENSE

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (3)

Showing the top 3 NuGet packages that depend on mostlylucid.consoleimage:

Package Downloads
mostlylucid.consoleimage.video

Video-to-ASCII renderer using FFmpeg. Streams video files as ASCII art with intelligent frame sampling, scene detection, and hardware acceleration. AOT compatible.

mostlylucid.consoleimage.spectre

Spectre.Console integration for ConsoleImage. Provides IRenderable implementations for displaying ASCII art, color blocks, and braille images within Spectre.Console layouts. Supports animated GIFs with Live display.

mostlylucid.consoleimage.transcription

Whisper-based audio transcription for ConsoleImage. Auto-generates subtitles from video/audio files using OpenAI Whisper models. Supports speaker diarization and multiple output formats (SRT, VTT).

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
4.5.1 60 2/1/2026
4.5.0 48 2/1/2026
4.5.0-rc1 35 2/1/2026
4.5.0-rc0 49 2/1/2026
4.5.0-alpha5 40 2/1/2026
4.5.0-alpha3 24 2/1/2026
4.5.0-alpha2 54 2/1/2026
4.5.0-alpha1 48 2/1/2026
4.5.0-alpha0 49 2/1/2026
4.1.2 251 1/26/2026
4.1.2-rc4 116 1/26/2026
4.1.2-rc3 115 1/26/2026
4.1.2-rc2 117 1/26/2026
4.1.2-rc1 110 1/26/2026
4.1.2-rc0 108 1/26/2026
4.1.1-alpha2 107 1/26/2026
4.1.1-alpha1 118 1/26/2026
4.1.1-alpha0 120 1/26/2026
4.1.0 114 1/25/2026
4.1.0-rc0 113 1/25/2026
4.1.0-alpha3 111 1/26/2026
4.1.0-alpha2 113 1/25/2026
4.1.0-alpha1 112 1/25/2026
4.1.0-alpha0 111 1/25/2026
4.0.0-rc4 113 1/25/2026
4.0.0-rc2 101 1/25/2026
4.0.0-rc1 102 1/25/2026
4.0.0-rc0 100 1/25/2026
3.2.0 108 1/24/2026
3.1.0 119 1/24/2026
3.0.3-alpha.0.1 40 1/24/2026
3.0.2 105 1/24/2026
3.0.0 103 1/24/2026
2.7.1 101 1/24/2026
2.7.0 104 1/24/2026
2.6.9-preview2 97 1/24/2026
2.6.9-preview1 101 1/24/2026
2.6.9-preview0 99 1/24/2026
2.6.6 111 1/22/2026
2.6.5 106 1/22/2026
2.6.4 106 1/22/2026
2.6.3 103 1/22/2026
2.6.1 101 1/22/2026
2.6.0 108 1/22/2026
2.5.1 103 1/22/2026
2.5.0 83 1/22/2026
2.3.0 84 1/21/2026
2.2.0 86 1/21/2026
2.1.0 88 1/21/2026
2.0.0 86 1/21/2026
2.0.0-alpha0 99 1/21/2026
1.6.0 80 1/20/2026
1.5.2 81 1/20/2026
1.5.1 85 1/20/2026
1.5.0 87 1/20/2026
1.3.0 75 1/20/2026
1.2.0 86 1/20/2026
1.1.0 91 1/18/2026
1.0.0 83 1/18/2026
0.0.2 84 1/18/2026
0.0.1 88 1/18/2026