使用Python 3获取base64编码字符串的格式

时间:2018-06-06 06:52:25

标签: python python-3.x base64

我在很多不同的地方搜索过但找不到答案。

似乎建议的猜测base64编码字符串扩展的方法(字符串中没有扩展名及其有效图像)是使用PIL包。这就是我目前正在做的事情。

但是当我尝试打开图像时,我收到错误cannot identify image file

有关我可能做错的任何建议吗?

#img_content is base64 encoded string     
decodedbytes = base64.decodebytes(str.encode(image_content))
image_stream = StringIO(str(decodedbytes))
image = Image.open(image_stream) #<-----ERROR
filetype = image.format

0 个答案:

没有答案