Flask中接收到的图像的形状

时间:2018-09-21 11:13:20

标签: python flask request

我想从POST请求接收图像,然后打印出图像形状。当我运行我的应用程序时,我会得到

  

对象没有属性“形状”

@app.route('/predict', methods=['POST'])
def take_image():
    input_file = request.files.get('file')
    image = input_file
    return image.shape

有什么建议吗?

1 个答案:

答案 0 :(得分:0)

您首先需要从输入文件中创建和图像对象

from PIL import Image
im = Image.open(input_file)
width, height = im.size

有关更多信息,请参见PIL documentation