'Python - image to bytes and vice versa

I'm having some problems with getting my original image back:

'''

# get image object from np.array
im = Image.fromarray(cv2.imread(array, cv2.IMREAD_UNCHANGED))
# transform to bytes
buffered = BytesIO()        
im.save(buffered, format="TIFF")       
img_bytes = Image.frombuffer("I;16", (960,810), buffered)       

# back to image:
image_obj = Image.frombytes("I;16", (960,810), img_bytes)         
image = np.array(image_obj)
'''

However, I don't get the same image that I had before and wondering what the problem is. The original object looks like this: <PIL.Image.Image image mode=I;16 size=960x810 at 0x1FEC478ACA0>

Thanks!



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source