mod opts; use crate::opts::Options; use clap::Parser; use std::path::Path; use thyme::{data::Mapping, file::ThymeFile, image::Image}; fn main() -> Result<(), Box> { // read the command-line options let opts = Options::parse(); let image_path = Path::new(&opts.image); // load the PNG image for the pattern let image = Image::load(image_path)?; // load the color map file let mapping = Mapping::load(opts.mapping, &image)?; let thyme = ThymeFile::from_image_and_config(&image, &mapping); let output_filename = match opts.output { Some(s) => Path::new(&s).to_path_buf(), None => { let mut path = image_path.to_path_buf(); path.set_extension("thyme"); path } }; { let mut f = std::fs::File::create(output_filename)?; thyme.to_stream(&mut f)?; } Ok(()) }