4 个版本 (1 个稳定版)
| 1.0.0 | 2022年6月10日 | 
|---|---|
| 0.1.2 | 2021年12月10日 | 
| 0.1.1 | 2021年12月10日 | 
| 0.1.0 | 2021年12月10日 | 
#940 在 命令行界面
每月 26 次下载
在  2 crates 中使用
12KB
146 行
ansipix
一个将图像转换为 ANSI 字符串以在终端中打印的 Rust 库
使用方法
添加依赖项
将以下内容添加到您的 Cargo.toml
ansipix = "1.0.0"
获取 ANSI 字符串
use std::path::PathBuf;
let img = ansipix::of_image_file(PathBuf::from("example.png"), (50, 50), 100, false);
match img {
    Ok(img) => println!("{}", img),
    Err(e) => eprintln!("{}", e),
}
有关更多信息,请参阅 文档。
指定不同的过滤器类型
ansipix 使用 image crate 打开和调整图像大小。函数 of_image_file 使用 FilterType::Nearest 进行调整大小。您可以使用 of_image_file_with_filter 函数指定不同的过滤器。
use std::path::PathBuf;
use ansipix::FilterType;
let img = ansipix::of_image_file_with_filter(PathBuf::from("example.png"), (32, 32), 255, false, FilterType::Triangle);
match img {
    Ok(img) => println!("{}", img),
    Err(e) => eprintln!("{}", e),
}
依赖项
~13MB
~60K SLoC