import io
from PIL import Image
imageFileObj = open(imageFilename, "rb")
imageBinaryBytes = imageFileObj.read()
imageStream = io.BytesIO(imageBinaryBytes)
imageFile = Image.open(imageStream)
print("imageFile.size=%s" % imageFile.size)
# checks this https://stackoverflow.com/questions/14759637/python-pil-bytes-to-image