| Crates.io | image_to_console_core |
| lib.rs | image_to_console_core |
| version | 0.2.2 |
| created_at | 2025-10-29 11:38:26.316358+00 |
| updated_at | 2025-11-06 11:22:34.583457+00 |
| description | A simple Rust library for converting images to terminal ASCII art, supporting multiple image formats and terminal output methods |
| homepage | https://github.com/yyxxryrx/image_to_console |
| repository | https://github.com/yyxxryrx/image_to_console |
| max_upload_size | |
| id | 1906462 |
| size | 374,776 |
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.
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.
sixel feature)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.
image crategif feature)Add this to your Cargo.toml:
[dependencies]
image_to_console_core = "0.1"
Basic usage example:
you can see in examples/basic-example.rs
use image::error::ImageResult;
use image_to_console_core::processor::{ImageProcessor, ImageProcessorOptions};
fn main() -> ImageResult<()> {
let img = image::open("path/to/image.png")?;
// Use default config
let option = ImageProcessorOptions::default();
let mut processor = ImageProcessor::new(img, option);
let result = processor.process();
// Exception handling (this is only shown, not handled, please refer to the actual use of the need)
let result = result.expect("Process image failed");
// result.lines contains the formatted terminal output
// you also can use display method to print
println!("{}", result.display());
Ok(())
}
or more simply
you can see in examples/simple-example.rs
use image::error::ImageResult;
use image_to_console_core::processor::{ImageProcessorOptions, ImageProcessorOptionsCreate};
fn main() -> ImageResult<()> {
let img = image::open("path/to/image.png")?;
// Use default config and process
let result = ImageProcessorOptions::default()
.create_processor(img)
.process()
.unwrap();
// result.lines contains the formatted terminal output
// you also can use display method to print
println!("{}", result.display());
Ok(())
}
or
you can see in examples/simple-example3.rs
use image::error::ImageResult;
use image_to_console_core::{print, processor::ImageProcessorOptions};
fn main() -> ImageResult<()> {
let img = image::open("path/to/image.png")?;
// create config
let config = ImageProcessorOptions::default();
// show image
print(&img, &config).expect("Show image error");
Ok(())
}
or
you can see in examples/simple-example2.rs
use image::error::ImageResult;
use image_to_console_core::show_image;
fn main() -> ImageResult<()> {
let img = image::open("path/to/image.png")?;
// show image
show_image!(img);
Ok(())
}
sixel - Enable Sixel graphics protocol supportgif - Enable GIF processing supportclap_support - clap support for Protocolauto_select - Auto select protocolall - Enable all features| 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 |
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.
This project is licensed under the MIT License - see the LICENSE file for details.