Cogito ergo sum

How to save a base46 encoded image on hard disk in Python

In some cases you receive an image as bas64 encoded string and you need to save it first on disk before you can reopen it and use it!

First of all you have to import base64 package.

import base64
encoded_image= base64.b64decode(YOUR_BASE64_ENCODED_IMAGE)
with open('your_image.jpg', 'wb') as f:

YOUR_BASE64_ENCODED_IMAGE is the base64 encoded string of the image.

About the author

Peshmerge Morad

A IT-student and a programmer based in the Netherlands whose interests span multiple fields.

Add comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Cogito ergo sum