image_ascii

Crates.ioimage_ascii
lib.rsimage_ascii
version0.1.1
sourcesrc
created_at2023-08-29 22:55:45.246091
updated_at2023-08-29 23:21:40.063842
descriptionA library to transform images into ASCII art. Both into text and images consisting of letters.
homepage
repository
max_upload_size
id958509
size9,534,309
(velvitoff)

documentation

README

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();
Commit count: 0

cargo fmt