fix: added try catch block to handle invalid images

This commit is contained in:
2023-06-16 08:28:14 +03:00
parent 30dfe88aa1
commit 7b20711720
2 changed files with 13 additions and 2 deletions
+5 -1
View File
@@ -168,4 +168,8 @@ poetry.toml
.ruff_cache/
# LSP config files
pyrightconfig.json
pyrightconfig.json
rejects/
done/
.vscode/
+8 -1
View File
@@ -1,5 +1,6 @@
import argparse
from pathlib import Path
import cv2
from sorter.image_sorter import process_image
# CLI argument parsing
@@ -28,7 +29,13 @@ def main():
# Process the images
for image_path in image_paths:
process_image(image_path, pass_folder, reject_folder)
"""
try catch block to handle errors in processing individual images.
"""
try:
process_image(image_path, pass_folder, reject_folder)
except cv2.error as e:
print(f"Error processing image {image_path.name}: {str(e)}")
print("Sorting complete.")