Python Forum
Binary data to Image convert - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: Binary data to Image convert (/thread-29226.html)



Binary data to Image convert - Nuwan16 - Aug-23-2020

In my case I stored binary data inside user collection as user_pic using mongoengine. It looks like this
"user_pic": {
        "$binary": {
            "base64": "/9j/4AAQSkZJRgABAQEAYABgAAD/2wBDABQODxI........
...........AooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKAP/2Q==",
            "subType": "00"
        }
    }
[When I convert this binary code to image using some online converters, It gives expected image]. So now I want to convert this binary code to image and show that images to users through user interface. Is there any way to do this?


RE: Binary data to Image convert - millpond - Aug-24-2020

This is Base64 encoding, often used in email and Usenet from the old days.

https://www.base64decoder.io/python/

Should be of help here...