diff --git a/Cargo.toml b/Cargo.toml index 16eae08..a31c524 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,3 +9,4 @@ rustc-serialize = "*" image = "*" complex = "*" dft = "*" +rust-crypto = "*" diff --git a/src/cache.rs b/src/cache.rs new file mode 100644 index 0000000..1ee76a5 --- /dev/null +++ b/src/cache.rs @@ -0,0 +1,30 @@ +// Copyright 2015 Drew Short . +// +// Licensed under the MIT license. +// This file may not be copied, modified, or distributed except according to those terms. + +extern image; + +use self::image::ImageBuffer; +use std::path::Path; + +/** + * Get the hash of the desired file and return it as a hex string + */ +fn get_file_hash(path: &Path) -> String { + +} + +/** + * Put an image buffer in the cache + */ +pub fn put_in_cache(path: &Path, image: &ImageBuffer) { + +} + +/** + * Get an image buffer out of the cache + */ +pub fn get_from_cache(path: &Path) -> Some(ImageBuffer) { + +} diff --git a/src/hash.rs b/src/hash.rs index f4c3873..a3fb7d6 100644 --- a/src/hash.rs +++ b/src/hash.rs @@ -51,6 +51,10 @@ pub struct PerceptualHashes<'a> { */ pub fn prepare_image(path: &Path, size: u32) -> PreparedImage { let image_path = path.to_str().unwrap(); + // Check if we have the already converted image in a cache and use that if possible. + + + // Otherwise let's do that work now and store it. let image = image::open(path).unwrap(); let small_image = image.resize_exact(size, size, FilterType::Lanczos3); let grey_image = small_image.to_luma(); diff --git a/src/lib.rs b/src/lib.rs index 6b2e675..b54aec8 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -6,6 +6,7 @@ use std::path::Path; mod hash; +mod cache; pub fn get_phashes(path: &Path) -> hash::PerceptualHashes { hash::get_perceptual_hashes(path, 8)