How to save base64 image in python flask server
You get error when doing base64.decodebytes(string)
because your variable string
is always equal to b'{b64_string}'. And it just has characters which are not in Base64 alphabet.
You could use something like:
def convert_and_save(b64_string): with open("imageToSave.png", "wb") as fh: fh.write(base64.decodebytes(b64_string.encode()))
Moreover, it's strange that you send JPEG files and save them with PNG filename extension.