Advertisement
Guest User

Untitled

a guest
Nov 7th, 2020
31
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. self.images_to_check.par_iter_mut().map(|file_entry| {
  2. let image = match image::open(file_entry.path.clone()) {
  3. Ok(t) => t,
  4. Err(_) => return, // Something is wrong with image
  5. };
  6. let dimensions = image.dimensions();
  7.  
  8. file_entry.dimensions = format!("{}x{}", dimensions.0, dimensions.1);
  9. let hasher = HasherConfig::with_bytes_type::<[u8; 8]>().to_hasher();
  10.  
  11. let hash = hasher.hash_image(&image);
  12. let mut buf = [0u8; 8];
  13. buf.copy_from_slice(&hash.as_bytes());
  14.  
  15. self.bktree.add(buf);
  16. self.image_hashes.entry(buf).or_insert_with(Vec::<FileEntry>::new);
  17. self.image_hashes.get_mut(&buf).unwrap().push(file_entry.clone());
  18. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement