|
@ -51,6 +51,10 @@ pub struct PerceptualHashes<'a> { |
|
|
*/
|
|
|
*/
|
|
|
pub fn prepare_image(path: &Path, size: u32) -> PreparedImage {
|
|
|
pub fn prepare_image(path: &Path, size: u32) -> PreparedImage {
|
|
|
let image_path = path.to_str().unwrap();
|
|
|
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 image = image::open(path).unwrap();
|
|
|
let small_image = image.resize_exact(size, size, FilterType::Lanczos3);
|
|
|
let small_image = image.resize_exact(size, size, FilterType::Lanczos3);
|
|
|
let grey_image = small_image.to_luma();
|
|
|
let grey_image = small_image.to_luma();
|
|
|