I am loading image through PIL open load() function and changing the pixels. I have to then send this to client through socket. How can I do this without saving the image first. In my current approach I save the image using save function and then open it as file in rb mode and send it. pic = Image.open (image_name) pixels = pic.load() #code to manipulate pixels of the image
#want to avoid this section
pic.save("anyname","png")
f = open("anyname.png","rb")
data = f.read()
client_connection.sendall(data)