how do you decode base64 image urls?

This works in Python3. The stuff before the string is just meta information that you need to skip over.

data='data:image/gif;base64,R0lGODlhAQABAIAAAP///////yH5BAEKAAEALAAAAAABAAEAAAICTAEAOw=='
img_data=data.split('base64,')[1].encode('utf8')
with open("imageToSave.gif", "wb") as fh:
    fh.write(base64.decodebytes(img_data))

The image appears to be a 1 pixel GIF. Presumably a tracker…

Source: Convert string in base64 to image and save on filesystem in Python

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top