//use image_similarity::descriptors::dct::DCT;
use image_similarity::descriptors::{DCT, Descriptor};
use std::path::PathBuf;
use base64::{engine::general_purpose::URL_SAFE_NO_PAD, Engine as _};
use log::debug;
use clap::Parser;

#[derive(Parser)]
#[command(version, about, long_about = None)]
struct Cfg {
    path: PathBuf
}

fn main() {
    env_logger::init();
    let cfg = Cfg::parse();

    let desc = DCT::new().with_quality(95);

    let img = image::open(cfg.path)
        .expect("Unable to open file");
    let phash: u64 = desc.describe(&img);
    debug!("Phash integer:\n{phash}");
    debug!("Phash binary:\n{phash:064b}");
    let output = URL_SAFE_NO_PAD.encode(phash.to_be_bytes());
    println!("{output}");
}
