2 releases
0.1.1 | Aug 29, 2023 |
---|---|
0.1.0 | Aug 29, 2023 |
#1495 in Text processing
7MB
171 lines
ascii_image
A simple Rust crate for transforming images into ascii art.
This project on Crates.io
This project on Github
Example
use image::{io::Reader as ImageReader, RgbaImage, DynamicImage, Rgba};
use rusttype::Font;
use image_ascii::ImageGenerator;
let image = ImageReader::open("tests/data/images/landscape.jpg")
.unwrap()
.decode()
.unwrap();
let bytes = std::fs::read("src/fonts/Ubuntu-Regular.ttf").unwrap();
let font = Font::try_from_bytes(&bytes).unwrap();
let res = ImageGenerator::new(&image, &font)
.set_scale_x(4)
.set_scale_y(4)
.set_text_color(image_ascii::ImageGeneratorTextColor::CopyFromImage)
.generate();
let res = image::imageops::resize(
&res,
image.width(),
image.height(),
image::imageops::FilterType::CatmullRom,
);
res.save("landscape.png").unwrap();
Dependencies
~14MB
~247K SLoC