mirror of
https://github.com/andwati/image-sort.git
synced 2026-11-18 22:45:11 +00:00
fix: added try catch block to handle invalid images
This commit is contained in:
@@ -169,3 +169,7 @@ poetry.toml
|
|||||||
|
|
||||||
# LSP config files
|
# LSP config files
|
||||||
pyrightconfig.json
|
pyrightconfig.json
|
||||||
|
|
||||||
|
rejects/
|
||||||
|
done/
|
||||||
|
.vscode/
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
import argparse
|
import argparse
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
import cv2
|
||||||
from sorter.image_sorter import process_image
|
from sorter.image_sorter import process_image
|
||||||
|
|
||||||
# CLI argument parsing
|
# CLI argument parsing
|
||||||
@@ -28,7 +29,13 @@ def main():
|
|||||||
|
|
||||||
# Process the images
|
# Process the images
|
||||||
for image_path in image_paths:
|
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.")
|
print("Sorting complete.")
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user