A rust implementation of skywatch-phash
1use miette::{IntoDiagnostic, Result};
2use std::env;
3use std::fs;
4use std::path::Path;
5
6fn main() -> Result<()> {
7 let args: Vec<String> = env::args().collect();
8
9 if args.len() != 2 {
10 eprintln!("Usage: {} <image-path>", args[0]);
11 eprintln!("\nComputes perceptual hash (aHash/average hash) for an image.");
12 eprintln!("Outputs 16-character hex string (64-bit hash).");
13 std::process::exit(1);
14 }
15
16 let image_path = Path::new(&args[1]);
17
18 if !image_path.exists() {
19 eprintln!("Error: File not found: {}", image_path.display());
20 std::process::exit(1);
21 }
22
23 // Read image bytes
24 let image_bytes = fs::read(image_path).into_diagnostic()?;
25
26 // Compute phash
27 let phash = skywatch_phash_rs::processor::phash::compute_phash(&image_bytes)?;
28
29 // Output just the hash
30 println!("{}", phash);
31
32 Ok(())
33}