#image #pixel #terminal #resize #printing

bin+lib print_image

Print an image to the terminal!

3 releases

0.1.2 Apr 7, 2024
0.1.1 Apr 7, 2024
0.1.0 Apr 7, 2024

#14 in #resize

Download history 266/week @ 2024-04-07 6/week @ 2024-04-14

272 downloads per month

Custom license

12KB
65 lines

Print Image

A super simple solution to printing images in the terminal

Features

  • Printing images
  • Resizing output
  • Custom pixel handling

Usage

use print_image;
use std::path::Path;

fn main() -> Result<(), print_image::PrintImageError> {
	print_img(
		Path::new("path/to/file.png"), 
		Some((12, 12)), 
		print_image::handle_pixel_rgb
	)
}

Custom Pixel Handler

use print_image;
use std::path::Path;

fn main() -> Result<(), print_image::PrintImageError> {
	print_img(
		Path::new("path/to/file.png"), 
		Some((12, 12)), 
		|pixel| {
			match pixel[0] {
				0..=128 => "+".to_string(),
				129..=255 => "-".to_string()
			}
		}
	)
}

Dependencies

  • image - Licensed under MIT or Apache 2.0
  • colored - Licensed under Mozilla Public License Version 2.0

99.99% of the legwork was done by the dependencies for this project. Print Image only provides an easy to use wrapper over them.

License

Code is licensed under MIT. Click here for more information.

Dependencies

~11–21MB
~107K SLoC