Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- self.images_to_check.par_iter_mut().map(|file_entry| {
- let image = match image::open(file_entry.path.clone()) {
- Ok(t) => t,
- Err(_) => return, // Something is wrong with image
- };
- let dimensions = image.dimensions();
- file_entry.dimensions = format!("{}x{}", dimensions.0, dimensions.1);
- let hasher = HasherConfig::with_bytes_type::<[u8; 8]>().to_hasher();
- let hash = hasher.hash_image(&image);
- let mut buf = [0u8; 8];
- buf.copy_from_slice(&hash.as_bytes());
- self.bktree.add(buf);
- self.image_hashes.entry(buf).or_insert_with(Vec::<FileEntry>::new);
- self.image_hashes.get_mut(&buf).unwrap().push(file_entry.clone());
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement