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 the base64 package.
import base64
decoded_image= base64.b64decode(YOUR_BASE64_ENCODED_IMAGE)
with open('your_image.jpg', 'wb') as f:
f.write(decoded_image)
YOUR_BASE64_ENCODED_IMAGE is the base64 encoded string of the image.
Leave a Reply