Convert Base 64 String to BytesIO
re.sub("data:image/jpeg;base64,", '', b64_str).decode("base64")
works in Python2. In Py 2, the str
is bytes
actually.
UPDATE
from base64 import b64decodewith open("test.jpeg", 'wb') as f: f.write(b64decode(re.sub("data:image/jpeg;base64,", '', b64_str)))# orimage = BytesIO(b64decode(re.sub("data:image/jpeg;base64", '', b64_str)))