Relevant Code:
import boto3
from PIL import Image
import base64
client = boto3.client('rekognition')
filename = r'C:\Users\H-63\Pictures\scantests\Rekognition test.JPG'
with open(filename, 'rb') as image_file:
image = image_file.read()
image = base64.b64encode(image).decode('UTF-8')
response = client.detect_text(
Image={'Bytes': image
})
However, When I run this, I get an error:
An error occurred (InvalidImageFormatException) when calling the DetectText operation: Request has Invalid image format
How do I get my image to be the right format for detect_text? The documentation says it has to be base64 encoding.