Skip to content

misobalogh/rustii_art

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🎨 Rustii Art

rustii_art logo

A high-performance ASCII art generator written in Rust

Convert images into stunning ASCII art with optional color support and automatic terminal fitting.

Quick StartOptionsHow It WorksPerformance


rustii_art is a high-performance ASCII art generator written in Rust that converts images into ASCII art with optional color support. The tool automatically detects terminal dimensions and scales images accordingly, making it easy to display artwork directly in your terminal.

Preview

Details
Colored ASCII Grayscale ASCII Landscape

Features

  • Automatic terminal detection - Fits images to your terminal size automatically
  • Grayscale and colored output - Convert to classic ASCII or vibrant colored ASCII art
  • Customizable character sets - Use your own charset for different visual styles

Quick Start

Installation

Build the project with Cargo:

cargo build --release

Usage

rustii_art <IMAGE_PATH> [OPTIONS]

Basic Examples

# Convert image to colored ASCII art, fit to terminal size
rustii_art examples/rustacean.png

# Generate grayscale ASCII art
rustii_art examples/rustacean.png --grayscale

# Custom dimensions
rustii_art examples/rustacean.png --width 40

# Inverted grayscale
rustii_art examples/rustacean.png --grayscale --invert

# Custom character sets
rustii_art examples/rustacean.png --charset "█▓▒░ "
rustii_art examples/rustacean.png --charset ":"
rustii_art examples/rustacean.png --charset "@"

Command Line Options

Option Description Default
<IMAGE_PATH> Path to the image file Required
--width <cols> Output width in characters Auto-detected
--height <rows> Output height in characters Auto-detected
--scale <f> Ratio of character height to width, with most fonts, it is around 2 2.0
--filter <type> Scaling filter (nearest, linear, cubic, gaussian, lanczos3) lanczos3
--charset <string> Custom character set .:-=+*#%@
--grayscale Enable grayscale output Disabled
--invert Invert brightness mapping Disabled

Use lanczos3 filter for best quality when resizing images, and nearest for fastest performance. You can experiment with different character sets and resizing filters to achieve various artistic effects.

How It Works

Image Processing Pipeline

  1. Load - Read the image file using the image crate
  2. Resize - Scale image to match terminal dimensions accounting for character aspect ratio
  3. Convert - Map pixel brightness to ASCII characters
  4. Output - Print to terminal

Brightness Mapping

  • Brightness is calculated using standard luminance formula: 0.299*R + 0.587*G + 0.114*B
  • Each pixel's brightness is mapped to a character in your charset

Color Support

Colored ASCII art uses ANSI escape sequences with 24-bit RGB color support (16.7 million colors):

\x1b[38;2;R;G;Bm<char>\x1b[0m

Performance

For optimal performance with large images:

  • The tool pre-allocates string buffers to minimize memory allocations
  • Images are resized before conversion to terminal size (not pixel-by-pixel processing)
  • Charset lookups are cached for faster character mapping

Dependencies

Author

Michal Balogh

About

ASCII art generator written in Rust

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages