I have the following code. It seems like img_1 and img_2 are not the same. Looking at the pixels, I can tell there is a small diff, which can be hardly seen, but becomes a big deal later. Why does it happen and how to read the version of img_2 directly from s3?
import matplotlib.pyplot as plt
import matplotlib.image as mpimg
import numpy as np
import boto3
import io
from PIL import Image, ImageChops
s3 = boto3.resource('s3', region_name='us-east-1')
bucket = s3.Bucket(bucket)
key = "some_key.jpeg"
object = bucket.Object(key)
response = object.get()
file_stream = response['Body']
img_1 = Image.open(file_stream)
img_1.save('/tmp/img1.jpeg')
img_2 = Image.open('/tmp/img1.jpeg')
diff = ImageChops.difference(img_1, img_2)
if diff.getbbox():
print("images are different")
else:
print("images are the same")