import cv2 import os def crop_image(image_path, crop_size, start_point): if image_path.endswith(".jpg") or image_path.endswith(".png"): image = cv2.imread(image_path) height, width = image.shape[:2] if width > start_point[0] + crop_size[0] and height > start_point[1] + crop_size[1]: cropped_image = image[start_point[1]:start_point[1]+crop_size[1], start_point[0]:start_point[0]+crop_size[0]] return cropped_image else: print(f"Image {os.path.basename(image_path)} is too small to be cropped with the current settings.") return False