Basic POC cli working
This commit is contained in:
commit
410e203f9e
9 changed files with 1433 additions and 0 deletions
27
src/main.rs
Normal file
27
src/main.rs
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
mod dithering;
|
||||
mod escpos;
|
||||
|
||||
use image::{ImageError, ImageReader};
|
||||
use std::{env, fs, io, io::Write, process};
|
||||
|
||||
fn main() {
|
||||
let args: Vec<String> = env::args().collect();
|
||||
|
||||
let len = args.len();
|
||||
if len < 2 || len > 2 {
|
||||
println!("Please provide a path to the image.");
|
||||
process::exit(1);
|
||||
}
|
||||
|
||||
let img = ImageReader::open(&args[1])
|
||||
.map_err(|err| ImageError::IoError(err))
|
||||
.and_then(|v| v.decode())
|
||||
.unwrap();
|
||||
|
||||
let mut escpos = escpos::escpos_raster(&img, Some(escpos::ImageOrientation::Largest), Some(0));
|
||||
for _ in 0..2 {
|
||||
escpos.push('\n' as u8);
|
||||
}
|
||||
|
||||
io::stdout().write(&escpos).unwrap();
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue