Python reading jpg file from s3 unidentified image error

27 Views Asked by At
#boto3 version = 1.28.3
#botocore version = 1.31.65

import boto3
from PIL import Image
from io import BytesIO

s3 = boto3.client('s3')
new_obj = s3.get_object(Bucket=bucket, Key="path/to/image_folder/image_3.jpg")
image_dl = new_obj['Body'].read()
image = Image.open(BytesIO(image_dl))

Error:

PIL.UnidentifiedImageError: Cannot identify image file

Any suggestions will be helpful

0

There are 0 best solutions below