尝试在Python中将base64字符串转换为图像时出错

时间:2020-07-19 21:07:06

标签: python image encoding web-applications decoding

我正在尝试创建一个Python仪表板,用户在其中上载图像,然后对图像进行分析。上载的图像将作为base64字符串接收,并且需要将其转换为图像。我尝试过

decoded = BytesIO(base64.b64decode(base64_string))
image = Image.open(decoded)

但我收到此错误:

无法识别图像文件<_io.BytesIO对象位于0x00000268954E9888>

1 个答案:

答案 0 :(得分:0)

echo '<form action="" method="post" enctype="multipart/form-data" name="openShiftForm" id="openShiftForm">'; echo '<input type="hidden" id="latlng" name="latlng" value="">'; echo '<input type="hidden" name="action" value="openShift">'; echo '<button type="button" onclick="addLatlng()" class="btn btn-danger btn-lg" name="openShift" value="1">'.$schichttypArray[intval($_SESSION['openSchichttyp'])]['name'].' 1Schicht &ouml;ffnen</button>'; echo '</form>'; 需要一个类似文件的对象,即Image返回的东西。最简单的方法是使用open语句:

with

看看是否更适合您。 :)