I have an image that I converted to bytes using the method below:
import io
from PIL import Image
def image_to_byte_array(image:Image):
imgByteArr = io.BytesIO()
image.save(imgByteArr, format=image.format)
imgByteArr = imgByteArr.getvalue()
return imgByteArr
Here is how I called the above method PIL Image.read() to covert it to bytes
im = Image.read('mam.JPG")
im_bytes = image_to_byte_array(im)
Now I want to reverse the process and convert the image back to a PIL Image. How do I do this ?