X-Git-Url: https://us-delaporte.pagekite.me/gitweb/dotfiles.git/blobdiff_plain/b4a9d4827c68ed11eb639bf2ef55c2c9e0aae413..refs/heads/main:/run/ocr/ocr.py?ds=sidebyside diff --git a/run/ocr/ocr.py b/run/ocr/ocr.py index 61a69ba..b1a2a32 100644 --- a/run/ocr/ocr.py +++ b/run/ocr/ocr.py @@ -25,7 +25,7 @@ def ocr_directory(input_dir): # Check if the file is an image if file_name.lower().endswith(('.png', '.jpg', '.jpeg', '.bmp', '.gif')): input_path = os.path.join(root, file_name) - output_path = os.path.join(root, file_name.replace('.', '_ocr.')) + output_path = f'{input_path}.ocr.json' text = None if os.path.exists(output_path): @@ -35,7 +35,7 @@ def ocr_directory(input_dir): text = ocr_image(ocr, input_path) if text: # Write the OCR result to a JSON file - json_output_path = output_path.rsplit('.', 1)[0] + '.json' + json_output_path = output_path.rsplit('.', 1)[0] with open(json_output_path, 'w') as f: f.write(f'{{"text": "{text}"}}')