A rust library for converting images to ANSI strings to print in a terminal
Add the following to your Cargo.toml
toml
ansipix = "0.1.2"
```rust use std::path::PathBuf;
let img = ansipix::of_image(PathBuf::from("path/to/image"), (50, 50), 100, false); ``` Refer to the docs for more information about the parameters.
ansipix
uses the image
crate for opening and resizing the image. The of_image
function uses FilterType::Nearest
for resizing. To specify a different one, add the image
crate to your dependencies and use of_image_with_filter
:
```rust
use std::path::PathBuf;
use image::imageops::FilterType;
let img = ansipix::ofimagewith_filter(PathBuf::from("path/to/image"), (32, 32), 255, false, FilterType::Triangle); ```
rust
println!("{}", img.unwrap_or_else(|e| {
eprintln!("Error while opening the file: {}", e);
std::process::exit(1);
}));