-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_image_processing.py
More file actions
36 lines (29 loc) · 1.14 KB
/
test_image_processing.py
File metadata and controls
36 lines (29 loc) · 1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
from invoice_renamer import InvoiceRenamer
import os
from PIL import Image
import pytesseract
def test_image_processing():
# Test directories
input_dir = r"E:\projects\LLM\test_rename"
output_dir = r"E:\projects\LLM\After_rename"
# Initialize renamer
renamer = InvoiceRenamer(input_dir, output_dir)
# Process only image files
for filename in os.listdir(input_dir):
if filename.lower().endswith(('.jpg', '.jpeg', '.png')):
file_path = os.path.join(input_dir, filename)
print(f"\nTesting image processing for: {filename}")
# Test image extraction
text = renamer.extract_text_from_image(file_path)
if text:
print("Successfully extracted text:")
print("-" * 40)
print(text[:200] + "..." if len(text) > 200 else text)
print("-" * 40)
else:
print("Failed to extract text from image")
image_path = "path/to/your/image.jpg"
image = Image.open(image_path)
print(image.size, image.mode)
if __name__ == "__main__":
test_image_processing()