image_to_console_core
This is the core library of
image_to_consoleproject - a Rust library for converting images to terminal ASCII art, supporting multiple image formats and terminal output methods.
Requirements
- Rust 1.85.0 or later (due to Rust 2024 edition)
Overview
image_to_console_core is a Rust library that converts images into terminal-friendly formats including ASCII art and
colored output. It supports various terminal protocols and image formats, making it easy to display images directly in
the terminal.
Features
- Multiple terminal protocols support:
- Standard colored output (24-bit color)
- Kitty graphics protocol
- WezTerm graphics protocol
- iTerm2 graphics protocol
- Sixel graphics protocol (with
sixelfeature)
Note: This library is primarily developed and tested on Windows. While Kitty and iTerm2 protocols are supported, they may require specific terminal emulators on Windows that fully support these protocols. For the best experience with these protocols, testing on macOS/Linux environments is recommended.
- Various image format support through the
imagecrate - Multiple display modes:
- Full color with background/foreground colors
- Half-block color mode
- ASCII mode
- No-color (grayscale) mode
- Image resizing with different algorithms
- GIF support (with
giffeature) - Parallel processing for better performance
- Compression options for more efficient output
Usage
Add this to your Cargo.toml:
[]
= "0.1"
Basic usage example:
you can see in examples/basic-example.rs
use ImageResult;
use ;
or more simply
you can see in examples/simple-example.rs
use ImageResult;
use ;
or
you can see in examples/simple-example2.rs
use ImageResult;
use show_image;
Features Flags
sixel- Enable Sixel graphics protocol supportgif- Enable GIF processing supportclap_support- clap support forProtocolauto_select- Auto select protocolall- Enable all features
Dependencies
| Crate | Version | License | Purpose |
|---|---|---|---|
| base64 | 0.22.1 | MIT | Base64 encoding |
| clap | 4.5.50 | MIT | Command line argument parsing (optional) |
| crossterm | 0.29.0 | MIT | Terminal control (optional) |
| gif | 0.13.3 | MIT | GIF animation decoding (optional) |
| image | 0.25.8 | MIT | Image encoding/decoding and processing |
| nohash-hasher | 0.2.0 | MIT | Sixel Fast Hash (optional) |
| num_cpus | 1.17.0 | MIT | Get logical CPU core count |
| quantette | 0.3.0 | MIT | Sixel image quantization (optional) |
| rayon | 1.11.0 | MIT | Data parallel computing |
| terminal_size | 0.4.3 | MIT | Detect terminal size |
Contributing
We welcome contributions! Please see CONTRIBUTING.md for detailed guidelines.
Note: This library is primarily developed on Windows. We especially appreciate testing and feedback on macOS/Linux for Kitty and iTerm2 protocols.
License
This project is licensed under the MIT License - see the LICENSE file for details.