1👍
✅
When you added the =
to the string the returned string from .decode("base64")
was the same as the input string minus the appended =
.
To write the .png
to a file you need to do the following:
head, data = chartStr.split(",", 1)
with open('foo.png',"wb") as f:
f.write(data.decode('base64'))
This removes the data:image/png;base64,
stuff and leaves you with some base64 encoded data.
Source:stackexchange.com