I have an image object that I've accepted via a streamlit interface. Here's its type: <class 'streamlit.uploaded_file_manager.UploadedFile'>
I need to get the size of this image in bytes or megabytes. The image is not stored on my device. I tried using
def img_resize(image):
img2 = Image.open(image)
img_file = io.BytesIO()
img2.save(img_file, 'png')
image_file_size = img_file.tell()
print(image_file_size)
img2.close()
# This function connects to azure services and generates the resources and generates the results
def azure_result(image_name, image):
img_resize(image)
Output: 14386671 2021-08-12 12:57:01.892 Traceback (most recent call last): File "path", line 1709, in read_in_stream raise models.ComputerVisionOcrErrorException(self._deserialize, response) azure.cognitiveservices.vision.computervision.models._models_py3.ComputerVisionOcrErrorException: Operation returned an invalid status code 'Bad Request'
The file size printed is 14386671, the image size as per the system is 3.77 mb. When i further pass the image object to the Azure Cognitive Service, I get a bad request error.
How do I solve this?

