Skip to content

Instantly share code, notes, and snippets.

@aspose-com-gists
Last active August 5, 2025 07:20
Show Gist options
  • Save aspose-com-gists/19cae59f7efd199ecd360ba6a0bb8ddc to your computer and use it in GitHub Desktop.
Save aspose-com-gists/19cae59f7efd199ecd360ba6a0bb8ddc to your computer and use it in GitHub Desktop.
Extract JPG Text Using Python and Aspose.OCR
import aspose.ocr as ocr
# Instantiate Aspose.OCR API
api = ocr.AsposeOcr()
# Add image to the recognition batch
img = ocr.OcrInput(ocr.InputType.SINGLE_IMAGE)
img.add("sample-with-text.jpg")
# Recognize the image
result = api.recognize(img)
# Print recognition result
print(result[0].recognition_text)
import aspose.ocr as ocr
# Instantiate Aspose.OCR API
api = ocr.AsposeOcr()
# Add image to the recognition batch
img = ocr.OcrInput(ocr.InputType.SINGLE_IMAGE)
img.add("sample.jpg")
# Recognize the image
result = api.recognize(img)
# Print recognition result
print(result[0].recognition_text)
# Save as DOCX
result[0].save("ImagetoDOCX.docx", ocr.SaveFormat.DOCX, ocr.PdfOptimizationMode.NONE)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment