mirror of
https://github.com/andwati/image-sort.git
synced 2026-10-18 00:22:51 +00:00
Added function to isolate images below 75kb
This commit is contained in:
+28
-1
@@ -10,7 +10,31 @@ max_value = 255
|
||||
threshold_type = cv2.THRESH_BINARY
|
||||
|
||||
|
||||
def process_image(image_path,pass_folder,reject_folder):
|
||||
def is_image_below_threshold(image_path, size_threshold):
|
||||
"""If the image size is below the threshold, regardless of the thresholding
|
||||
result, the image will be moved to the reject folder.
|
||||
|
||||
Args:
|
||||
image_path (_type_): _description_
|
||||
size_threshold (_type_): _description_
|
||||
|
||||
Returns:
|
||||
_type_: _description_
|
||||
"""
|
||||
image_path = Path(image_path)
|
||||
size = image_path.stat().st_size
|
||||
return size < size_threshold
|
||||
|
||||
|
||||
def process_image(image_path,pass_folder,reject_folder,size_threshold=75*1024):
|
||||
"""_summary_
|
||||
|
||||
Args:
|
||||
image_path (_type_): _description_
|
||||
pass_folder (_type_): _description_
|
||||
reject_folder (_type_): _description_
|
||||
size_threshold (_type_, optional): _description_. Defaults to 75*1024.
|
||||
"""
|
||||
image_path = Path(image_path)
|
||||
filename = image_path.name
|
||||
image = cv2.imread(str(image_path))
|
||||
@@ -25,4 +49,7 @@ def process_image(image_path,pass_folder,reject_folder):
|
||||
else:
|
||||
destination_folder = reject_folder
|
||||
|
||||
if is_image_below_threshold(image_path, size_threshold):
|
||||
destination_folder = reject_folder
|
||||
|
||||
shutil.move(str(image_path), str(destination_folder / filename))
|
||||
Reference in New Issue
Block a user