ansee
A command-line tool for converting ANSI-escaped text to images. Supports 256 colors, RGB colors, and custom fonts.
Features
- Convert ANSI-escaped text to PNG images
- Support for standard ANSI colors (16 colors)
- Extended color support (256 colors)
- True color support (RGB)
- Custom font support
- Configurable font size and line height
- Input from file or stdin
- Output to file or stdout
Installation
Make sure you have Rust installed on your system. Then:
# Clone the repository
# Build and install
Usage
Basic Usage
# Convert ANSI text from a file
# Convert ANSI text from stdin
|
# Use a specific font
# Customize font size and line height
Available Options
Usage: ansee [OPTIONS] [INPUT] [COMMAND]
Arguments:
[INPUT] Input file to render or stdin if not present
Options:
-o, --output <OUTPUT> Output file to write to or stdout if not present
-f, --font <FONT> Font used for rendering the image
-s, --font-size <SIZE> Font size in pixels [default: 20.0]
-e, --line-height <HEIGHT> Line height in a factor of height [default: 1.1]
-h, --help Print help
-V, --version Print version
Commands:
list-fonts List available font families that can be used
help Print this message or help for given subcommand
Font Management
To list all available monospace fonts on your system:
ANSI Support
The tool supports the following ANSI escape sequences:
- Standard colors (30-37, 40-47)
- Bright colors (90-97, 100-107)
- 256 colors (38;5;n, 48;5;n)
- RGB colors (38;2;r;g;b, 48;2;r;g;b)
- Reset (0)
- Italic (3)
- Reverse color (7)
Examples
Basic Text Coloring
|
Using 256 Colors
|
Using RGB Colors
|
Library Usage
You can use ansee as a library in your Rust projects. Add it to your Cargo.toml:
[]
= { = "https://github.com/codersauce/ansee" }
Example
use draw_image;
API Reference
draw_image
Converts ANSI-escaped text to an image. Returns an ImageBuffer that can be saved or manipulated further.
Font struct
Or you can convert from a colon delimited &str, like FantasqueSansM:18.0:1.2 and try_into:
draw_image;
The library provides full access to the same functionality as the CLI tool, allowing you to:
- Render ANSI-escaped text with color support
- Customize fonts and text appearance
- Generate images programmatically
- Integrate with existing Rust applications
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Acknowledgments
- Uses ab_glyph for font rendering
- Uses image for image processing
- Uses ansi-parser for ANSI escape sequence parsing