๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
๐Ÿ‘จ๐Ÿผ‍๐Ÿ’ป๊ฐœ๋ฐœ/ํŒŒ์ด์ฌ

ํŒŒ์ด์ฌ - base64๋ฅผ ์ด๋ฏธ์ง€ ํŒŒ์ผ๋กœ ์ €์žฅํ•˜๊ธฐ

by Janger 2021. 12. 8.
728x90
๋ฐ˜์‘ํ˜•
import base64
imgdata = base64.b64decode(imgstring)
filename = 'some_image.jpg'  # I assume you have a way of picking unique filenames
with open(filename, 'wb') as f:
    f.write(imgdata)
# f gets closed when you exit the with statement
# Now save the value of filename to your database

 

์ถœ์ฒ˜: 

https://stackoverflow.com/questions/16214190/how-to-convert-base64-string-to-image/16214280

 

How to convert base64 string to image?

I'm converting an image to base64 string and sending it from android device to the server. Now, I need to change that string back to an image and save it in the database. Any help?

stackoverflow.com

 

728x90
๋ฐ˜์‘ํ˜•