ascii-rs

Crates.ioascii-rs
lib.rsascii-rs
version0.1.2
sourcesrc
created_at2024-10-12 06:13:21.15423
updated_at2024-10-12 06:21:18.822594
descriptionProcess image into colored-ascii image
homepage
repository
max_upload_size
id1406165
size552,714
Thomas Bui (itsthomashere)

documentation

README

Process image into colored ascii image

Usage

  • Render to stdout
use rascii::image_proc::ImageEngine;
use std::error::Error;
use std::io::stdout;

fn main() -> Result<(), Box<dyn Error>> {
    let source = image::open("charizard.png")?;
    let engine = ImageEngine::new(source);

    let mut writer = stdout();

    engine.render_to_text(&mut writer, 0, Some(256), None)?;
    Ok(())
}
  • Write into a file

use rustascii::{image_proc::ImageEngine};
use std::{error::Error, io::stdout};
   
fn main() -> Result<(), Box<dyn Error>> {
    let source = include_bytes!("charizard");
    let engine = ImageEngine::from_slice(source)?;
    
   let mut file_writer = fs::File::create_new("your-new-file")?;
    
    // If only one of the axis is set,
    // the image aspect ratio will be preserved
    engine.render_to_text(&mut file_writer, 0, Some(128), None)?;
    Ok(())
}

Demo

  • Origin Origin Image

  • Rendered

  • Rendered Image

Commit count: 0

cargo fmt