grok: pyton code, image to text ( telu+ eng), with all are in single rows,

 


# it worked, image to text, slight modifiations is required.
from PIL import Image
import pytesseract
import os

# Path to input image and output text file
image_path = '/content/123.jpg'
output_path = '/content/image_to_text.txt'

# Check if image exists
if not os.path.exists(image_path):
    raise FileNotFoundError(f"Image file {image_path} not found")

# Load the image
image = Image.open(image_path)

# Configure Tesseract for Telugu and English
tesseract_config = r'--oem 3 --psm 6 -l tel+eng'

# Extract text from the image
text = pytesseract.image_to_string(image, config=tesseract_config)

# Save the extracted text to a file
with open(output_path, 'w', encoding='utf-8') as file:
    file.write(text)

print(f"Text file saved at {output_path}")

Popular posts from this blog

SAP CPI : camle expression in sap cpi , cm, router, filter and groovy script. format

SAP CPI camel conditions and xpath conditions

oauth call to cpi integraiton suite from sap apim