diff --git a/crop_this_size.py b/crop_this_size.py new file mode 100755 index 0000000..5584668 --- /dev/null +++ b/crop_this_size.py @@ -0,0 +1,35 @@ +#! /usr/bin/env python3 +import pathlib +import subprocess +import argparse +from multiprocessing import Pool + + +if __name__ == "__main__": + parser = argparse.ArgumentParser("Batch crop standard sized images") + parser.add_argument("indir", type=pathlib.Path) + parser.add_argument("outdir", type=pathlib.Path) + + args = parser.parse_args() + args.outdir.mkdir(exist_ok=True) + + def convert_file(infile: pathlib.Path): + print(f"Splitting {infile}") + newf = args.outdir.joinpath(infile.stem) + + subprocess.run( + [ + "convert", + str(infile), + "+repage", + "-crop", + "2x2@", + "+repage", + f"{newf}_%d.png", + ] + ) + + with Pool() as pool: + print("Splitting images") + for _ in pool.imap_unordered(convert_file, args.indir.iterdir(), chunksize=1): + pass diff --git a/src/main.rs b/src/main.rs index 1d149a1..fbbbcc6 100644 --- a/src/main.rs +++ b/src/main.rs @@ -606,7 +606,7 @@ fn main() { active_resolution ); } else { - // option.set_int(&mut 300).unwrap(); + option.set_int(&mut 600).unwrap(); let active_resolution = option.get_int().unwrap(); let resolutions = option.int_constraints().unwrap(); print!("\t\t"); @@ -648,6 +648,7 @@ fn main() { break 'image_loop; } if scanbutton.get_bool().unwrap() { + println!("SCANNING..."); break 'button_loop; } } @@ -658,12 +659,13 @@ fn main() { let since_unix = now.duration_since(std::time::UNIX_EPOCH).unwrap(); let mut imagepath = dir.join(format!( - "plate_{}:{}.png", + "plate_{}_{}.png", since_unix.as_secs(), since_unix.subsec_millis() )); assert!(!imagepath.exists()); + println!("SAVING IMAGE..."); image.save(imagepath).unwrap(); } } else {