Repository: qarmin/czkawka (language: rust)

Issue:
Hash-size
Within windows_czkawka_cli-image 4.1.0, so within its help documentation for the image subset of commands, it is said that one of the choices could be hash-size: 4  (-c, --hash-size <hash-size>         Hash size (allowed: 4, 8, 16) [default: 8]).

But choosing this "4" will lead to an error message: "error: Invalid value for '--hash-size <hash-size>': Couldn't parse the image hash size (allowed: 8, 16, 32, 64)".

Could this be changed within the help documentation, and then, also for the 32 and 64 hash-sizes? And, is it still hash-size 8 that is the default, I wonder?

PS Now to me it looks like # 767, by qarmin, is because of this issue, so # 766, but what I meant was the help documentation coming with the program itself, so by entering the -h parameter at the command line: "C:\Program Files\zonder installatie\Czkawka_cli>windows_czkawka_cli image -h", in my case. 

Meanwhile, I have found that the default value for the hash-size is probably 8 indeed, for I have found 957 results for _"n_ images which have similar friends" while stating "-c 8" as a parameter at the command line, against 955 results for _"n_ images which have similar friends" while stating no parameter for that at the command line, so using the default for the hash-size, for the same set of about 30,000 images.


Discussion / hints:

Fix patch:
diff --git a/Cargo.lock b/Cargo.lock
index 0c5192c6b..714559772 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -221,9 +221,9 @@ checksum = "37ccbd214614c6783386c1af30caf03192f17891059cecc394b4fb119e363de3"
 
 [[package]]
 name = "bytemuck"
-version = "1.9.1"
+version = "1.10.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "cdead85bdec19c194affaeeb670c0e41fe23de31459efd1c174d049269cf02cc"
+checksum = "c53dfa917ec274df8ed3c572698f381a24eef2efba9492d797301b72b6db408a"
 
 [[package]]
 name = "byteorder"
@@ -455,9 +455,9 @@ dependencies = [
 
 [[package]]
 name = "crypto-common"
-version = "0.1.3"
+version = "0.1.4"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "57952ca27b5e3606ff4dd79b0020231aaf9d6aa76dc05fd30137538c50bd3ce8"
+checksum = "5999502d32b9c48d492abe66392408144895020ec4709e549e840799f3bb74c0"
 dependencies = [
  "generic-array",
  "typenum",
@@ -1415,9 +1415,9 @@ dependencies = [
 
 [[package]]
 name = "infer"
-version = "0.8.1"
+version = "0.9.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "e035cede526e0b21d5adffc9fa0eb4ef5d6026fe9c5b0bfe8084b9472b587a55"
+checksum = "f178e61cdbfe084aa75a2f4f7a25a5bb09701a47ae1753608f194b15783c937a"
 dependencies = [
  "cfb",
 ]
@@ -1810,9 +1810,9 @@ dependencies = [
 
 [[package]]
 name = "once_cell"
-version = "1.12.0"
+version = "1.13.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "7709cef83f0c1f58f666e746a08b21e0085f7440fa6a29cc194d68aac97a4225"
+checksum = "18a6dbe30758c9f83eb00cbea4ac95966305f5a7772f3f42ebfc7fc7eddbd8e1"
 
 [[package]]
 name = "opaque-debug"
@@ -2887,9 +2887,9 @@ dependencies = [
 
 [[package]]
 name = "trash"
-version = "2.1.4"
+version = "2.1.5"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "7d0492e349e41bfa40e9d446a5803b84275898f0b3bda568b23e10325702095d"
+checksum = "fe090367848cd40c4230ff3ce4e2ff6a2fd511c1e14ae047a4a4c37ef7965236"
 dependencies = [
  "chrono",
  "libc",
@@ -2924,9 +2924,9 @@ checksum = "dcf81ac59edc17cc8697ff311e8f5ef2d99fcbd9817b34cec66f90b6c3dfd987"
 
 [[package]]
 name = "ucd-trie"
-version = "0.1.3"
+version = "0.1.4"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "56dee185309b50d1f11bfedef0fe6d036842e3fb77413abef29f8f8d1c5d4c1c"
+checksum = "89570599c4fe5585de2b388aab47e99f7fa4e9238a1399f707a02e356058141c"
 
 [[package]]
 name = "unic-langid"
diff --git a/czkawka_cli/src/commands.rs b/czkawka_cli/src/commands.rs
index 49a18b6d4..7cebd0056 100644
--- a/czkawka_cli/src/commands.rs
+++ b/czkawka_cli/src/commands.rs
@@ -145,7 +145,7 @@ pub enum Commands {
         hash_alg: HashAlg,
         #[clap(short = 'z', long, default_value = "Lanczos3", parse(try_from_str = parse_similar_image_filter), help = "Hash algorithm (allowed: Lanczos3, Nearest, Triangle, Faussian, Catmullrom)")]
         image_filter: FilterType,
-        #[clap(short = 'c', long, default_value = "8", parse(try_from_str = parse_image_hash_size), help = "Hash size (allowed: 4, 8, 16)")]
+        #[clap(short = 'c', long, default_value = "16", parse(try_from_str = parse_image_hash_size), help = "Hash size (allowed: 8, 16, 32, 64)")]
         hash_size: u8,
     },
     #[clap(name = "music", about = "Finds same music by tags", help_message = HELP_MESSAGE, after_help = "EXAMPLE:\n    czkawka music -d /home/rafal -f results.txt")]
diff --git a/czkawka_core/Cargo.toml b/czkawka_core/Cargo.toml
index 3d2cf9a9e..d9d02e70a 100644
--- a/czkawka_core/Cargo.toml
+++ b/czkawka_core/Cargo.toml
@@ -63,7 +63,7 @@ imagepipe = "0.5.0"
 
 # Checking for invalid extensions
 mime_guess = "2.0.4"
-infer = "0.8.0"
+infer = "0.9.0"
 
 num_cpus = "1.13.1"
 
diff --git a/czkawka_core/i18n/en/czkawka_core.ftl b/czkawka_core/i18n/en/czkawka_core.ftl
index d523ab447..1bac2fc3c 100644
--- a/czkawka_core/i18n/en/czkawka_core.ftl
+++ b/czkawka_core/i18n/en/czkawka_core.ftl
@@ -1,4 +1,5 @@
 # Core
+core_similarity_original = Original
 core_similarity_very_high = Very High
 core_similarity_high = High
 core_similarity_medium = Medium
@@ -26,7 +27,7 @@ core_directory_overlap = Directories: All directories to search overlaps with ex
 core_directory_unable_to_get_device_id = Directories: Unable to get device id from folder { $path }
 
 core_ffmpeg_not_found = Cannot find proper installation of FFmpeg
-core_ffmpeg_not_found_windows = When using Windows be sure that ffmpeg.exe and ffprobe.exe are available in PATH or are put directly to same folder where is app executable
+core_ffmpeg_not_found_windows = Be sure that ffmpeg.exe and ffprobe.exe are available in PATH or are put directly to same folder where is app executable
 core_ffmpeg_missing_in_snap = Similar Videos don't work currently with snap, if you want help look at - { $url }
 
 core_saving_to_cache = Saved to file { $number } cache entries
diff --git a/czkawka_core/src/similar_images.rs b/czkawka_core/src/similar_images.rs
index 4baa43009..7e303bb3c 100644
--- a/czkawka_core/src/similar_images.rs
+++ b/czkawka_core/src/similar_images.rs
@@ -1247,7 +1247,9 @@ pub fn get_string_from_similarity(similarity: &u32, hash_size: u8) -> String {
     // }
     // #[cfg(not(debug_assertions))]
 
-    if *similarity <= SIMILAR_VALUES[index_preset][0] {
+    if *similarity == 0 {
+        flc!("core_similarity_original")
+    } else if *similarity <= SIMILAR_VALUES[index_preset][0] {
         flc!("core_similarity_very_high")
     } else if *similarity <= SIMILAR_VALUES[index_preset][1] {
         flc!("core_similarity_high")
@@ -1347,6 +1349,9 @@ pub fn test_image_conversion_speed() {
 }
 
 #[allow(dead_code)]
+// Function to validate if after first check there are any duplicated entries
+// E.g. /a.jpg is used also as master and similar image which is forbidden, because may
+// cause accidentally delete more pictures that user wanted
 fn debug_check_for_duplicated_things(
     hashes_parents: HashMap<&Vec<u8>, u32>,
     hashes_similarity: HashMap<&Vec<u8>, (&Vec<u8>, u32)>,
diff --git a/czkawka_core/src/similar_videos.rs b/czkawka_core/src/similar_videos.rs
index 372ace74e..01e7722d2 100644
--- a/czkawka_core/src/similar_videos.rs
+++ b/czkawka_core/src/similar_videos.rs
@@ -203,7 +203,9 @@ impl SimilarVideos {
     pub fn find_similar_videos(&mut self, stop_receiver: Option<&Receiver<()>>, progress_sender: Option<&futures::channel::mpsc::UnboundedSender<ProgressData>>) {
         if !check_if_ffmpeg_is_installed() {
             self.text_messages.errors.push(flc!("core_ffmpeg_not_found"));
+            #[cfg(target_os = "windows")]
             self.text_messages.errors.push(flc!("core_ffmpeg_not_found_windows"));
+            #[cfg(target_os = "linux")]
             self.text_messages.errors.push(flc!(
                 "core_ffmpeg_missing_in_snap",
                 generate_translation_hashmap(vec![("url", "https://github.com/snapcrafters/ffmpeg/issues/73".to_string())])
@@ -803,7 +805,7 @@ pub fn load_hashes_from_file(text_messages: &mut Messages, delete_outdated_cache
 }
 
 fn get_cache_file() -> String {
-    "cache_similar_videos_50.bin".to_string()
+    "cache_similar_videos.bin".to_string()
 }
 
 pub fn check_if_ffmpeg_is_installed() -> bool {
diff --git a/czkawka_gui/src/saving_loading.rs b/czkawka_gui/src/saving_loading.rs
index 8fe555b40..87be6cf98 100644
--- a/czkawka_gui/src/saving_loading.rs
+++ b/czkawka_gui/src/saving_loading.rs
@@ -755,7 +755,7 @@ pub fn load_configuration(
 
     let combo_box_duplicate_hash_type = loaded_entries.get_object(hashmap_ls.get(&LoadText::ComboBoxDuplicateHashType).unwrap().clone(), 0);
     let combo_box_duplicate_checking_method = loaded_entries.get_object(hashmap_ls.get(&LoadText::ComboBoxDuplicateCheckMethod).unwrap().clone(), 0);
-    let combo_box_image_hash_size = loaded_entries.get_object(hashmap_ls.get(&LoadText::ComboBoxImageHashSize).unwrap().clone(), 0);
+    let combo_box_image_hash_size = loaded_entries.get_object(hashmap_ls.get(&LoadText::ComboBoxImageHashSize).unwrap().clone(), 1); // 16 instead default 8
     let combo_box_image_hash_algorithm = loaded_entries.get_object(hashmap_ls.get(&LoadText::ComboBoxImageHashType).unwrap().clone(), 0);
     let combo_box_image_resize_algorithm = loaded_entries.get_object(hashmap_ls.get(&LoadText::ComboBoxImageResizeAlgorithm).unwrap().clone(), 0);
     let combo_box_big_files_mode = loaded_entries.get_object(hashmap_ls.get(&LoadText::ComboBoxBigFiles).unwrap().clone(), 0);
@@ -1033,7 +1033,7 @@ pub fn reset_configuration(manual_clearing: bool, upper_notebook: &GuiUpperNoteb
         main_notebook.combo_box_duplicate_check_method.set_active(Some(0));
         main_notebook.combo_box_image_hash_algorithm.set_active(Some(0));
         main_notebook.combo_box_image_resize_algorithm.set_active(Some(0));
-        main_notebook.combo_box_image_hash_size.set_active(Some(0));
+        main_notebook.combo_box_image_hash_size.set_active(Some(1)); // Set as 16 instead 8
         main_notebook.combo_box_big_files_mode.set_active(Some(0));
 
         main_notebook.check_button_broken_files_audio.set_active(DEFAULT_BROKEN_FILES_AUDIO);


Test patch: