]> us-delaporte.pagekite.me Git - dotfiles.git/blobdiff - run/ocr/ocr.py
Use editor for invoke tasks
[dotfiles.git] / run / ocr / ocr.py
index 61a69ba41b74f9db1e0211591330c54c0decd2ea..b1a2a32fa7f79ed8d46aed71a8ce5983d336d8e9 100644 (file)
@@ -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}"}}')