A high-performance ASCII art generator written in Rust
Convert images into stunning ASCII art with optional color support and automatic terminal fitting.
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.
- 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
Build the project with Cargo:
cargo build --releaserustii_art <IMAGE_PATH> [OPTIONS]# 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 "@"| 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.
- Load - Read the image file using the
imagecrate - Resize - Scale image to match terminal dimensions accounting for character aspect ratio
- Convert - Map pixel brightness to ASCII characters
- Output - Print to terminal
- 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
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
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
image- Image loading and manipulationclap- Command-line argument parsingcrossterm- Getting terminal dimensionsanyhow,thiserror- Error handling
Michal Balogh


