我想根据要求发送图像(通过 URL 或路径)。我在这里使用源代码。 该代码已经有一个发送图像的示例(通过 URL 或路径),但我不明白,因为我是 Python 新手。
这是示例代码片段:
elif text == '/image': #request
img = Image.new('RGB', (512, 512))
base = random.randint(0, 16777216)
pixels = [base+i*j for i in range(512) for j in range(512)] # generate sample image
img.putdata(pixels)
output = StringIO.StringIO()
img.save(output, 'JPEG')
reply(img=output.getvalue())
一些 API 信息可以在这里找到。
谢谢你的耐心。