BUGFIX: image processing only handles filenames with jpg

This commit is contained in:
B.J. Dweck 2023-09-21 14:42:47 +03:00
parent e96f23ddc8
commit 963d99404e

View File

@ -44,7 +44,11 @@ def convert_image(image_path):
def ocr_image(image_path): def ocr_image(image_path):
logging.info(f"OCR'ing {image_path}...") logging.info(f"OCR'ing {image_path}...")
text_filename = os.path.basename(image_path).replace(".jpg", ".txt")
base_name = os.path.basename(image_path)
root_name, _ = os.path.splitext(base_name)
text_filename = f"{root_name}.txt"
text_path = os.path.join(CONVERTED_DIR, text_filename) text_path = os.path.join(CONVERTED_DIR, text_filename)
cmd = ["tesseract", image_path, text_path.replace(".txt", "")] cmd = ["tesseract", image_path, text_path.replace(".txt", "")]
try: try: