I am trying to convert an byte array to PNG
image and save it to a specific folder. The byte array comes from a C#
server, python
client will receive it and save as PNG
image.
I tried the following way:
reply = s.recv(4096)
image = Image.open(io.BytesIO(reply))
image.save("img1.png","PNG")
It gives following error:
Traceback (most recent call last):
File "C:\Users\imran.s\Desktop\UnityClient.py", line 46, in <module>
image.save("img1.png","PNG")
File "C:\python64\lib\site-packages\PIL\Image.py", line 1895, in save
self.load()
File "C:\python64\lib\site-packages\PIL\ImageFile.py", line 233, in load
"(%d bytes not processed)" % len(b))
OSError: image file is truncated (3 bytes not processed)