Based on this stackoverflow post, this worked:
<line_from_your_gist_assigning_to_string>
import base64
with open("imageToSave.png", "wb") as fh:
fh.write(base64.decodebytes(str.encode(string)))
Replace the <line_from_your_gist_assigning_to_string>
with the raw content of your gist.
Used the route of my_str_as_bytes
from this stackoverflow post to convert your string
text to bytes.
However, I found that replacing the str.encode(string)
part of my suggested code with string.encode()
, and according to Antti Haapala’s answer that may perhaps be better.