I tried encoding an image and decoding the same in python shell. The first time I open the decoded base64 string in PIL there is no error, if I repeat the Image.open() comma
image_string is file-like object. File-like object has file position.
Once the file is read, the position is advanced.
Any subsequent is occurred at that position unless you explicitly position it using seek method.
So if you want to reopen the file:
...
image_string.seek(0) # reset file position to the beginning of the file.
img = Image.open(image_string)