dctfilename binary in base64
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
use image_similarity::descriptors::{Descriptor, DCT};
|
||||
use std::env;
|
||||
use base64::{engine::general_purpose::URL_SAFE_NO_PAD, Engine as _};
|
||||
|
||||
struct Cfg {
|
||||
path: String
|
||||
}
|
||||
|
||||
impl Cfg{
|
||||
fn load(args: &[String]) -> Result<Cfg, &'static str> {
|
||||
if args.len() < 2 {
|
||||
return Err("Filename argument required");
|
||||
}
|
||||
let path = args[1].clone();
|
||||
Ok(Cfg { path })
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
//Init all descriptors:
|
||||
let desc = DCT;
|
||||
|
||||
let args: Vec<String> = env::args().collect();
|
||||
//dbg!(args);
|
||||
|
||||
let cfg = Cfg::load(&args)
|
||||
.expect("Error loading config");
|
||||
|
||||
let img = image::open(cfg.path)
|
||||
.expect("Unable to open file");
|
||||
let phash: u64 = desc.describe(img);
|
||||
println!("{phash}\n{phash:b}");
|
||||
let output = URL_SAFE_NO_PAD.encode(phash.to_be_bytes());
|
||||
println!("{output}")
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user