본문 바로가기
파이썬

파이썬 base64 문자열을 이미지로 변환하는 방법은 무엇입니까?

by º기록 2021. 1. 19.
반응형

이미지를 base64 문자열로 변환하고 Android 기기에서 서버로 보냅니다. 이제 해당 문자열을 이미지로 다시 변경하고 데이터베이스에 저장해야합니다.

도움이 필요하세요?

 

해결 방법

 

이 시도:

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

 

 

반응형

댓글