in seed/util/preprocess.py [0:0]
def crop_image_from_file(file_path, page_number, bounding_box):
"""
Crop an image from a file.
Args:
file_path (str): The path to the file.
page_number (int): The page number (for PDF and TIFF files, 0-indexed).
bounding_box (tuple): The bounding box coordinates in the format (x0, y0, x1, y1).
Returns:
A PIL Image of the cropped area.
"""
mime_type = mimetypes.guess_type(file_path)[0]
if mime_type == "application/pdf":
return crop_image_from_pdf_page(file_path, page_number, bounding_box)
else:
return crop_image_from_image(file_path, page_number, bounding_box)